mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
fixes
This commit is contained in:
+14
-6
@@ -276,6 +276,7 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) {
|
||||
struct MHD_Session * pos;
|
||||
struct MHD_Session * prev;
|
||||
struct MHD_HTTP_Header * hpos;
|
||||
void * unused;
|
||||
|
||||
pos = daemon->connections;
|
||||
prev = NULL;
|
||||
@@ -285,6 +286,8 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) {
|
||||
daemon->connections = pos->next;
|
||||
else
|
||||
prev->next = pos->next;
|
||||
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
||||
pthread_join(pos->pid, &unused);
|
||||
free(pos->addr);
|
||||
if (pos->url != NULL)
|
||||
free(pos->url);
|
||||
@@ -299,6 +302,7 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) {
|
||||
pos->headers_received = hpos->next;
|
||||
free(hpos->header);
|
||||
free(hpos->value);
|
||||
free(hpos);
|
||||
}
|
||||
if (pos->response != NULL)
|
||||
MHD_destroy_response(pos->response);
|
||||
@@ -337,6 +341,7 @@ MHD_select(struct MHD_Daemon * daemon,
|
||||
fd_set es;
|
||||
int max;
|
||||
struct timeval timeout;
|
||||
int ds;
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
@@ -373,16 +378,22 @@ MHD_select(struct MHD_Daemon * daemon,
|
||||
strerror(errno));
|
||||
return MHD_NO;
|
||||
}
|
||||
if (FD_ISSET(daemon->socket_fd,
|
||||
ds = daemon->socket_fd;
|
||||
if (ds == -1)
|
||||
return MHD_YES;
|
||||
if (FD_ISSET(ds,
|
||||
&rs))
|
||||
MHD_accept_connection(daemon);
|
||||
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) {
|
||||
/* do not have a thread per connection, process all connections now */
|
||||
pos = daemon->connections;
|
||||
while (pos != NULL) {
|
||||
if (FD_ISSET(pos->socket_fd, &rs))
|
||||
ds = pos->socket_fd;
|
||||
if (ds == -1)
|
||||
continue;
|
||||
if (FD_ISSET(ds, &rs))
|
||||
MHD_session_handle_read(pos);
|
||||
if (FD_ISSET(pos->socket_fd, &ws))
|
||||
if (FD_ISSET(ds, &ws))
|
||||
MHD_session_handle_write(pos);
|
||||
pos = pos->next;
|
||||
}
|
||||
@@ -542,9 +553,6 @@ MHD_stop_daemon(struct MHD_Daemon * daemon) {
|
||||
close(daemon->connections->socket_fd);
|
||||
daemon->connections->socket_fd = -1;
|
||||
}
|
||||
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
||||
pthread_join(daemon->connections->pid, &unused);
|
||||
|
||||
MHD_cleanup_sessions(daemon);
|
||||
}
|
||||
free(daemon);
|
||||
|
||||
@@ -131,14 +131,14 @@ static int testInternalGet() {
|
||||
return 2;
|
||||
}
|
||||
curl_easy_cleanup(c);
|
||||
if (cbc.pos != strlen("hello_world")) {
|
||||
if (cbc.pos != strlen("/hello_world")) {
|
||||
MHD_stop_daemon(d);
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (0 != strncmp("hello_world",
|
||||
if (0 != strncmp("/hello_world",
|
||||
cbc.buf,
|
||||
strlen("hello_world"))) {
|
||||
strlen("/hello_world"))) {
|
||||
MHD_stop_daemon(d);
|
||||
return 8;
|
||||
}
|
||||
@@ -190,16 +190,18 @@ static int testMultithreadedGet() {
|
||||
curl_easy_setopt(c,
|
||||
CURLOPT_NOSIGNAL,
|
||||
1);
|
||||
if (CURLE_OK != curl_easy_perform(c))
|
||||
if (CURLE_OK != curl_easy_perform(c)) {
|
||||
MHD_stop_daemon(d);
|
||||
return 32;
|
||||
}
|
||||
curl_easy_cleanup(c);
|
||||
if (cbc.pos != strlen("hello_world")) {
|
||||
if (cbc.pos != strlen("/hello_world")) {
|
||||
MHD_stop_daemon(d);
|
||||
return 64;
|
||||
}
|
||||
if (0 != strncmp("hello_world",
|
||||
if (0 != strncmp("/hello_world",
|
||||
cbc.buf,
|
||||
strlen("hello_world"))) {
|
||||
strlen("/hello_world"))) {
|
||||
MHD_stop_daemon(d);
|
||||
return 128;
|
||||
}
|
||||
|
||||
@@ -250,6 +250,8 @@ MHD_destroy_response(struct MHD_Response * response) {
|
||||
}
|
||||
pthread_mutex_unlock(&response->mutex);
|
||||
pthread_mutex_destroy(&response->mutex);
|
||||
if (response->crfc != NULL)
|
||||
response->crfc(response->crc_cls);
|
||||
while (response->first_header != NULL) {
|
||||
pos = response->first_header;
|
||||
response->first_header = pos->next;
|
||||
|
||||
@@ -275,8 +275,6 @@ MHD_parse_session_headers(struct MHD_Session * session) {
|
||||
session->headers_received = hdr;
|
||||
}
|
||||
/* FIXME: here: find cookie header and parse that! */
|
||||
if (session->bodyReceived == 0)
|
||||
return;
|
||||
return;
|
||||
DIE:
|
||||
close(session->socket_fd);
|
||||
|
||||
Reference in New Issue
Block a user