diff options
Diffstat (limited to 'src/lib/daemon_info.c')
-rw-r--r-- | src/lib/daemon_info.c | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/src/lib/daemon_info.c b/src/lib/daemon_info.c index b0c5ec14..d32f244b 100644 --- a/src/lib/daemon_info.c +++ b/src/lib/daemon_info.c | |||
@@ -43,62 +43,62 @@ | |||
43 | */ | 43 | */ |
44 | enum MHD_Bool | 44 | enum MHD_Bool |
45 | MHD_daemon_get_information_sz (struct MHD_Daemon *daemon, | 45 | MHD_daemon_get_information_sz (struct MHD_Daemon *daemon, |
46 | enum MHD_DaemonInformationType info_type, | 46 | enum MHD_DaemonInformationType info_type, |
47 | union MHD_DaemonInformation *return_value, | 47 | union MHD_DaemonInformation *return_value, |
48 | size_t return_value_size) | 48 | size_t return_value_size) |
49 | { | 49 | { |
50 | #define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \ | 50 | #define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \ |
51 | return MHD_NO | 51 | return MHD_NO |
52 | 52 | ||
53 | switch (info_type) | 53 | switch (info_type) |
54 | { | 54 | { |
55 | case MHD_DAEMON_INFORMATION_LISTEN_SOCKET: | 55 | case MHD_DAEMON_INFORMATION_LISTEN_SOCKET: |
56 | CHECK_SIZE (MHD_socket); | 56 | CHECK_SIZE (MHD_socket); |
57 | return_value->listen_socket | 57 | return_value->listen_socket |
58 | = daemon->listen_socket; | 58 | = daemon->listen_socket; |
59 | return MHD_YES; | 59 | return MHD_YES; |
60 | #ifdef EPOLL_SUPPORT | 60 | #ifdef EPOLL_SUPPORT |
61 | case MHD_DAEMON_INFORMATION_EPOLL_FD: | 61 | case MHD_DAEMON_INFORMATION_EPOLL_FD: |
62 | CHECK_SIZE (int); | 62 | CHECK_SIZE (int); |
63 | // FIXME: maybe return MHD_NO if we are not using EPOLL? | 63 | // FIXME: maybe return MHD_NO if we are not using EPOLL? |
64 | return_value->epoll_fd = daemon->epoll_fd; | 64 | return_value->epoll_fd = daemon->epoll_fd; |
65 | return MHD_YES; | 65 | return MHD_YES; |
66 | #endif | 66 | #endif |
67 | case MHD_DAEMON_INFORMATION_CURRENT_CONNECTIONS: | 67 | case MHD_DAEMON_INFORMATION_CURRENT_CONNECTIONS: |
68 | CHECK_SIZE (unsigned int); | 68 | CHECK_SIZE (unsigned int); |
69 | if (MHD_TM_EXTERNAL_EVENT_LOOP == daemon->threading_mode) | 69 | if (MHD_TM_EXTERNAL_EVENT_LOOP == daemon->threading_mode) |
70 | { | 70 | { |
71 | /* Assumes that MHD_run() in not called in other thread | 71 | /* Assumes that MHD_run() in not called in other thread |
72 | (of the application) at the same time. */ | 72 | (of the application) at the same time. */ |
73 | MHD_connection_cleanup_ (daemon); | 73 | MHD_connection_cleanup_ (daemon); |
74 | return_value->num_connections | 74 | return_value->num_connections |
75 | = daemon->connections; | 75 | = daemon->connections; |
76 | } | ||
77 | else if (daemon->worker_pool) | ||
78 | { | ||
79 | unsigned int i; | ||
80 | /* Collect the connection information stored in the workers. */ | ||
81 | return_value->num_connections = 0; | ||
82 | for (i = 0; i < daemon->worker_pool_size; i++) | ||
83 | { | ||
84 | /* FIXME: next line is thread-safe only if read is atomic. */ | ||
85 | return_value->num_connections | ||
86 | += daemon->worker_pool[i].connections; | ||
87 | } | ||
88 | } | ||
89 | else | ||
90 | return_value->num_connections | ||
91 | = daemon->connections; | ||
92 | return MHD_YES; | ||
93 | case MHD_DAEMON_INFORMATION_BIND_PORT: | ||
94 | CHECK_SIZE (uint16_t); | ||
95 | // FIXME: return MHD_NO if port is not known/UNIX? | ||
96 | return_value->port = daemon->listen_port; | ||
97 | return MHD_YES; | ||
98 | default: | ||
99 | return MHD_NO; | ||
100 | } | 76 | } |
101 | 77 | else if (daemon->worker_pool) | |
78 | { | ||
79 | unsigned int i; | ||
80 | /* Collect the connection information stored in the workers. */ | ||
81 | return_value->num_connections = 0; | ||
82 | for (i = 0; i < daemon->worker_pool_size; i++) | ||
83 | { | ||
84 | /* FIXME: next line is thread-safe only if read is atomic. */ | ||
85 | return_value->num_connections | ||
86 | += daemon->worker_pool[i].connections; | ||
87 | } | ||
88 | } | ||
89 | else | ||
90 | return_value->num_connections | ||
91 | = daemon->connections; | ||
92 | return MHD_YES; | ||
93 | case MHD_DAEMON_INFORMATION_BIND_PORT: | ||
94 | CHECK_SIZE (uint16_t); | ||
95 | // FIXME: return MHD_NO if port is not known/UNIX? | ||
96 | return_value->port = daemon->listen_port; | ||
97 | return MHD_YES; | ||
98 | default: | ||
99 | return MHD_NO; | ||
100 | } | ||
101 | |||
102 | #undef CHECK_SIZE | 102 | #undef CHECK_SIZE |
103 | } | 103 | } |
104 | 104 | ||