static int sapi_thttpd_ub_write(const char *str, uint str_length TSRMLS_DC) { int n; uint sent = 0; if (TG(sbuf).c != 0) { smart_str_appendl_ex(&TG(sbuf), str, str_length, 1); return str_length; } while (str_length > 0) { PHP_SYS_CALL(n = send(TG(hc)->conn_fd, str, str_length, 0);); if (n == -1) { if (errno == EAGAIN) { smart_str_appendl_ex(&TG(sbuf), str, str_length, 1); return sent + str_length; } else php_handle_aborted_connection(); } TG(hc)->bytes_sent += n; str += n; sent += n; str_length -= n; }
static inline long hs_response_recv(php_stream *stream, char *recv, size_t size TSRMLS_DC) { long ret; #ifdef HS_DEBUG long i; smart_str debug = {0}; #endif ret = php_stream_read(stream, recv, size); if (ret <= 0) { return -1; } recv[size] = '\0'; #ifdef HS_DEBUG for (i = 0; i < ret; i++) { if ((unsigned char)recv[i] == HS_CODE_NULL) { smart_str_appendl_ex(&debug, "\\0", strlen("\\0"), 1); } else { smart_str_appendc(&debug, recv[i]); } } smart_str_0(&debug); php_printf("[handlersocket] (recv) %ld : \"%s\"", ret, debug.c); smart_str_free(&debug); #endif return ret; }