fix(windows): resolve PR blockers — nanosleep shim, unsetenv, duplicate typedefs, SOCKET type, el_closesocket
El SDK CI - stage / build-and-test (pull_request) Failing after 22s
El SDK CI - stage / build-and-test (pull_request) Failing after 22s
This commit is contained in:
@@ -1061,7 +1061,6 @@ el_val_t http_post_to_file(el_val_t url, el_val_t body, el_val_t headers_map, el
|
||||
|
||||
#define HTTP_MAX_CONNS 64
|
||||
|
||||
typedef el_val_t (*http_handler_fn)(el_val_t method, el_val_t path, el_val_t body);
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
@@ -1536,12 +1535,20 @@ static void http_send_response(int fd, const char* body) {
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
#ifdef _WIN32
|
||||
SOCKET fd;
|
||||
#else
|
||||
int fd;
|
||||
#endif
|
||||
} HttpWorkerArg;
|
||||
|
||||
static void* http_worker(void* arg) {
|
||||
HttpWorkerArg* a = (HttpWorkerArg*)arg;
|
||||
#ifdef _WIN32
|
||||
SOCKET fd = a->fd;
|
||||
#else
|
||||
int fd = a->fd;
|
||||
#endif
|
||||
free(a);
|
||||
char *method = NULL, *path = NULL, *body = NULL;
|
||||
if (http_read_request(fd, &method, &path, &body, NULL) == 0) {
|
||||
@@ -1573,7 +1580,7 @@ static void* http_worker(void* arg) {
|
||||
free(response);
|
||||
}
|
||||
free(method); free(path); free(body);
|
||||
close(fd);
|
||||
el_closesocket(fd);
|
||||
/* release a slot */
|
||||
pthread_mutex_lock(&_http_conn_mu);
|
||||
_http_conn_active--;
|
||||
@@ -1610,7 +1617,11 @@ el_val_t http_serve(el_val_t port, el_val_t handler) {
|
||||
while (1) {
|
||||
struct sockaddr_in6 cli;
|
||||
socklen_t clen = sizeof(cli);
|
||||
#ifdef _WIN32
|
||||
SOCKET cfd = accept(sock, (struct sockaddr*)&cli, &clen);
|
||||
#else
|
||||
int cfd = accept(sock, (struct sockaddr*)&cli, &clen);
|
||||
#endif
|
||||
if (cfd < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
perror("accept"); break;
|
||||
@@ -1656,8 +1667,6 @@ el_val_t http_serve(el_val_t port, el_val_t handler) {
|
||||
* separate active-handler slot, separate dlsym fallback. Mixing v1 and v2
|
||||
* handlers in the same process is fine — they don't share the active slot. */
|
||||
|
||||
typedef el_val_t (*http_handler4_fn)(el_val_t method, el_val_t path,
|
||||
el_val_t headers_map, el_val_t body);
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
@@ -1793,7 +1802,11 @@ static el_val_t http_build_headers_map(const char* hdr_block) {
|
||||
|
||||
static void* http_worker_v2(void* arg) {
|
||||
HttpWorkerArg* a = (HttpWorkerArg*)arg;
|
||||
#ifdef _WIN32
|
||||
SOCKET fd = a->fd;
|
||||
#else
|
||||
int fd = a->fd;
|
||||
#endif
|
||||
free(a);
|
||||
char *method = NULL, *path = NULL, *body = NULL, *hdr_block = NULL;
|
||||
if (http_read_request(fd, &method, &path, &body, &hdr_block) == 0) {
|
||||
@@ -1823,7 +1836,7 @@ static void* http_worker_v2(void* arg) {
|
||||
free(response);
|
||||
}
|
||||
free(method); free(path); free(body); free(hdr_block);
|
||||
close(fd);
|
||||
el_closesocket(fd);
|
||||
pthread_mutex_lock(&_http_conn_mu);
|
||||
_http_conn_active--;
|
||||
pthread_cond_signal(&_http_conn_cv);
|
||||
@@ -1860,7 +1873,11 @@ el_val_t http_serve_v2(el_val_t port, el_val_t handler) {
|
||||
while (1) {
|
||||
struct sockaddr_in6 cli;
|
||||
socklen_t clen = sizeof(cli);
|
||||
#ifdef _WIN32
|
||||
SOCKET cfd = accept(sock, (struct sockaddr*)&cli, &clen);
|
||||
#else
|
||||
int cfd = accept(sock, (struct sockaddr*)&cli, &clen);
|
||||
#endif
|
||||
if (cfd < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
perror("accept"); break;
|
||||
|
||||
Reference in New Issue
Block a user