Hi all,
I am developing a server program with kqueue. The program is multithreaded and each thread has its own kqueue created. Each thread has its listening socket listening to the same port (through SO_REUSEPORT). When it runs there is no error at bind() and listen(), or registering with kqueue. However the accept callback is not triggered, no connection can be made, or only triggered on one of the listening ports. At development, it runs on vmware freebsd 11.2 guest. When i upload it to a bhyve freebsd vm (11.2 too) to test, all ports are responding and connections are all working.
I use kqueue in multithreaded code due to the need of shared data among workers. Freebsd kqueue is not quite threaded friendly. If one single kqueue and one listening port are used for all the threads, I got strange problems like unexpected event fired right after an event on the same socket even EV_DISPATCH + EV_CLEAR is used. Try with kqeueu per thread to fix this but have the above problem.
Thanks
I am developing a server program with kqueue. The program is multithreaded and each thread has its own kqueue created. Each thread has its listening socket listening to the same port (through SO_REUSEPORT). When it runs there is no error at bind() and listen(), or registering with kqueue. However the accept callback is not triggered, no connection can be made, or only triggered on one of the listening ports. At development, it runs on vmware freebsd 11.2 guest. When i upload it to a bhyve freebsd vm (11.2 too) to test, all ports are responding and connections are all working.
I use kqueue in multithreaded code due to the need of shared data among workers. Freebsd kqueue is not quite threaded friendly. If one single kqueue and one listening port are used for all the threads, I got strange problems like unexpected event fired right after an event on the same socket even EV_DISPATCH + EV_CLEAR is used. Try with kqeueu per thread to fix this but have the above problem.
Thanks