1
0
mirror of https://github.com/lammertb/libhttp.git synced 2026-01-27 08:02:47 +03:00

Moved close_all_listening_sockets to own file

This commit is contained in:
Lammert Bies
2016-12-10 11:53:41 +01:00
parent 2f06d5b1e2
commit e4a3a72643
3 changed files with 7 additions and 24 deletions

View File

@@ -45,6 +45,7 @@ LIB_SOURCES = src/libhttp.c \
src/httplib_accept_new_connection.c \
src/httplib_check_acl.c \
src/httplib_check_feature.c \
src/httplib_close_all_listening_sockets.c \
src/httplib_close_connection.c \
src/httplib_close_socket_gracefully.c \
src/httplib_connect_client.c \

View File

@@ -850,6 +850,7 @@ const char * XX_httplib_get_rel_url_at_current_server( const char *uri, const s
void XX_httplib_get_system_name( char **sysName );
int XX_httplib_get_uri_type( const char *uri );
int XX_httplib_getreq( struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err );
void XX_httplib_handle_file_based_request( struct mg_connection *conn, const char *path, struct file *filep );
void XX_httplib_handle_request( struct mg_connection *conn );
int XX_httplib_initialize_ssl( struct mg_context *ctx );
int XX_httplib_is_valid_port( unsigned long port );

View File

@@ -1533,8 +1533,6 @@ static int send_static_cache_header(struct mg_connection *conn) {
}
static void handle_file_based_request(struct mg_connection *conn, const char *path, struct file *filep);
void XX_httplib_send_http_error( struct mg_connection *conn, int status, const char *fmt, ... ) {
char buf[MG_BUF_LEN];
@@ -1603,7 +1601,7 @@ void XX_httplib_send_http_error( struct mg_connection *conn, int status, const c
if (page_handler_found) {
conn->in_error_handler = 1;
handle_file_based_request(conn, buf, &error_page_file);
XX_httplib_handle_file_based_request(conn, buf, &error_page_file);
conn->in_error_handler = 0;
return;
}
@@ -7789,7 +7787,7 @@ void XX_httplib_handle_request( struct mg_connection *conn ) {
/* 10. File is handled by a script. */
if (is_script_resource) {
handle_file_based_request(conn, path, &file);
XX_httplib_handle_file_based_request(conn, path, &file);
return;
}
@@ -7878,7 +7876,7 @@ void XX_httplib_handle_request( struct mg_connection *conn ) {
}
}
handle_file_based_request(conn, path, &file);
XX_httplib_handle_file_based_request(conn, path, &file);
#endif /* !defined(NO_FILES) */
#if 0
@@ -7893,7 +7891,7 @@ void XX_httplib_handle_request( struct mg_connection *conn ) {
} /* XX_httplib_handle_request */
static void handle_file_based_request(struct mg_connection *conn, const char *path, struct file *file) {
void XX_httplib_handle_file_based_request( struct mg_connection *conn, const char *path, struct file *file ) {
if ( conn == NULL || conn->ctx == NULL ) return;
@@ -7911,22 +7909,5 @@ static void handle_file_based_request(struct mg_connection *conn, const char *pa
handle_not_modified_static_file_request(conn, file);
#endif /* !NO_CACHING */
} else handle_static_file_request(conn, path, file, NULL, NULL);
}
void XX_httplib_close_all_listening_sockets( struct mg_context *ctx ) {
unsigned int i;
if ( ctx == NULL ) return;
for (i = 0; i < ctx->num_listening_sockets; i++) {
closesocket(ctx->listening_sockets[i].sock);
ctx->listening_sockets[i].sock = INVALID_SOCKET;
}
XX_httplib_free(ctx->listening_sockets);
ctx->listening_sockets = NULL;
XX_httplib_free(ctx->listening_socket_fds);
ctx->listening_socket_fds = NULL;
} /* XX_close_all_listening_sockets */
} /* XX_httplib_handle_file_based_request */