MCPcopy Index your code
hub / github.com/php/frankenphp / go_ub_write

Function go_ub_write

frankenphp.go:427–468  ·  view source on GitHub ↗

export go_ub_write

(threadIndex C.uintptr_t, cBuf *C.char, length C.size_t)

Source from the content-addressed store, hash-verified

425
426//export go_ub_write
427func go_ub_write(threadIndex C.uintptr_t, cBuf *C.char, length C.size_t) (C.size_t, C.bool) {
428 thread := phpThreads[threadIndex]
429 fc := thread.frankenPHPContext()
430
431 if fc.isDone {
432 return 0, C.bool(true)
433 }
434
435 var writer io.Writer
436 if fc.responseWriter == nil {
437 var b bytes.Buffer
438 // log the output of the worker
439 writer = &b
440 } else {
441 writer = fc.responseWriter
442 }
443
444 var ctx context.Context
445
446 i, e := writer.Write(unsafe.Slice((*byte)(unsafe.Pointer(cBuf)), length))
447 if e != nil {
448 ctx = thread.context()
449
450 if fc.logger.Enabled(ctx, slog.LevelWarn) {
451 fc.logger.LogAttrs(ctx, slog.LevelWarn, "write error", slog.Any("error", e))
452 }
453 }
454
455 if fc.responseWriter == nil {
456 // probably starting a worker script, log the output
457
458 if ctx == nil {
459 ctx = thread.context()
460 }
461
462 if fc.logger.Enabled(ctx, slog.LevelInfo) {
463 fc.logger.LogAttrs(ctx, slog.LevelInfo, writer.(*bytes.Buffer).String())
464 }
465 }
466
467 return C.size_t(i), C.bool(fc.clientHasClosed())
468}
469
470//export go_apache_request_headers
471func go_apache_request_headers(threadIndex C.uintptr_t) (*C.go_string, C.size_t) {

Callers

nothing calls this directly

Calls 5

clientHasClosedMethod · 0.80
frankenPHPContextMethod · 0.65
contextMethod · 0.65
WriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected