summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e78462d)
raw | patch | inline | side by side (parent: e78462d)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 20 Dec 2013 08:18:34 +0000 (09:18 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 20 Dec 2013 08:18:34 +0000 (09:18 +0100) |
The number is passed to listen_and_serve() as part of sdb_fe_loop_t.
src/frontend/sock.c | patch | blob | history | |
src/include/frontend/sock.h | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index b5a3dcdd6a2082af6f0b6ab0a75e23fb9a9b99dc..0c4829e2efc4d3737fb9cf4a5f21cf3df5fa59b5 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
int max_listen_fd = 0;
size_t i;
- /* XXX: make the number of threads configurable */
- pthread_t handler_threads[5];
+ pthread_t handler_threads[loop->num_threads];
size_t num_threads;
- if ((! sock) || (! sock->listeners_num) || (! loop) || sock->chan)
+ if ((! sock) || (! sock->listeners_num) || sock->chan
+ || (! loop) || (loop->num_threads <= 0))
return -1;
if (! loop->do_loop)
return -1;
}
- num_threads = SDB_STATIC_ARRAY_LEN(handler_threads);
+ sdb_log(SDB_LOG_INFO, "frontend: Starting %d connection "
+ "handler thread%s managing %d listener%s",
+ loop->num_threads, loop->num_threads == 1 ? "" : "s",
+ sock->listeners_num, sock->listeners_num == 1 ? "" : "s");
+
+ num_threads = loop->num_threads;
memset(&handler_threads, 0, sizeof(handler_threads));
for (i = 0; i < num_threads; ++i) {
errno = 0;
index 6ab8ccadbf9ebb4ebee101a2701e9e43d57cb296..7d1fd7a3ceed81995e790921a2258949d8d25f7a 100644 (file)
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <unistd.h>
+
#ifndef SDB_FRONTEND_SOCK_H
#define SDB_FRONTEND_SOCK_H 1
/* manage a front-end listener loop */
typedef struct {
+ /* number of handler threads to create */
+ size_t num_threads;
+
+ /* front-end listener shuts down when this is set to false */
_Bool do_loop;
} sdb_fe_loop_t;
-#define SDB_FE_LOOP_INIT { 1 }
+#define SDB_FE_LOOP_INIT { 5, 1 }
/*
* sdb_fe_socket_t: