diff options
author | robertabcd <robertabcd@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2014-10-11 18:21:04 +0800 |
---|---|---|
committer | robertabcd <robertabcd@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2014-10-11 18:21:04 +0800 |
commit | 7ca57260e684c486ae0e24e94e3d9cefc8b88b3d (patch) | |
tree | 3afc7de743842492c6bb287523bc149da0444af8 | |
parent | 578c44710fa24f8d3df856fa000b82aebcded3f3 (diff) | |
download | pttbbs-7ca57260e684c486ae0e24e94e3d9cefc8b88b3d.tar pttbbs-7ca57260e684c486ae0e24e94e3d9cefc8b88b3d.tar.gz pttbbs-7ca57260e684c486ae0e24e94e3d9cefc8b88b3d.tar.bz2 pttbbs-7ca57260e684c486ae0e24e94e3d9cefc8b88b3d.tar.lz pttbbs-7ca57260e684c486ae0e24e94e3d9cefc8b88b3d.tar.xz pttbbs-7ca57260e684c486ae0e24e94e3d9cefc8b88b3d.tar.zst pttbbs-7ca57260e684c486ae0e24e94e3d9cefc8b88b3d.zip |
daemon/barebone: add |SERVER_USE_PTHREADS| option to support threading.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@6081 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/daemon/barebone/server.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pttbbs/daemon/barebone/server.c b/pttbbs/daemon/barebone/server.c index df347abd..c23ef4d0 100644 --- a/pttbbs/daemon/barebone/server.c +++ b/pttbbs/daemon/barebone/server.c @@ -29,6 +29,9 @@ #include <event2/bufferevent.h> #include <event2/util.h> #include <event2/listener.h> +#ifdef SERVER_USE_PTHREADS +#include <event2/thread.h> +#endif #include "server.h" @@ -78,7 +81,7 @@ setup_client(struct event_base *base, evutil_socket_t fd, struct sockaddr *address, int socklen) { struct bufferevent *bev = bufferevent_socket_new(base, fd, - BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS); + BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS | BEV_OPT_THREADSAFE); bufferevent_setcb(bev, client_read_cb, NULL, client_event_cb, NULL); bufferevent_set_timeouts(bev, common_timeout, common_timeout); bufferevent_enable(bev, EV_READ|EV_WRITE); @@ -125,9 +128,17 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } +#ifdef SERVER_USE_PTHREADS + evthread_use_pthreads(); +#endif + base = event_base_new(); assert(base); +#ifdef SERVER_USE_PTHREADS + evthread_make_base_notifiable(base); +#endif + common_timeout = event_base_init_common_timeout(base, &timeout); if (!inetd) { |