-
Notifications
You must be signed in to change notification settings - Fork 663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch socket timeout logic to use poll()
instead of select()
#168
Comments
Why don't you use setsockopt with SO_SNDTIMEO / SO_RCVTIMEO for timeouts? |
That was actually what was used for the first (unreleased) iteration of the timeout code. Unfortunately it was not well supported across different platforms, especially Win32 where the docs suggest that if a timeout occurs on a socket, the socket should be considered in an undefined state and should be closed. |
Our system core dump the day before yesterday because of select() :( (The sockfd > 1024) |
there's a define to increase the ammount of descriptors in the select mask, FD_SETSIZE if i'm not mistaken |
redis fixed this in 2012
|
We use rabbitmq-c in our online game server, which hold about 8K TCP connections for players in one process . rabbitmq-c is for the platform message queue. The rabbitmq-c works fine usually because the platform message queue established at the beginning , the sockfd is very small at that time. But the connection for platform message queue was broken last week, and the server try to reestablish it immediately. And then, it crashed . We check the core dump file and found amqp_open_socket_noblock() couldn't return because the return address on stack was 0 , and portnumber_string[] was zero ,too. So I guess the reason is socketfd was too large at that time, and select() wipe the stack. |
It wasn't |
@alanxz I checked the core dump file, all the portnumber_string[] were set to zero after select. But FD_SET() only call twice before select (set 2 bits to 1) , so I guess select() clear them. It seems that select() doesn't know the size of fd_set on Linux, it use nfds (the first parameter of select) as the size of fd_set , it may clear the bits in them. |
Hey, Alan. We have faced an interesting problem in our application.
We are using very small timeout for consuming: timeval timeout = { 0, 1000 }, so we don't spend too much time for consuming and don't affecting our publish rate, but still have some throttling. We found that sometimes, in very rare situation, amqp_consume_message can "hang" until something arrived in the socket. We've made some investigation and we suspect that there is a problem with select in the code. quote: We gonna check this using some test with consuming thread being bombed with signals to force EINTR. We also think that poll() could fix this. Thanks for your library and sorry for my weak english =) |
Use poll(2) instead of select(2) to do timeout operations on sockets. This helps with the situation where the fd is larger than FD_MAXSIZE. Fixes #168
Use poll(2) instead of select(2) to do timeout operations on sockets. This helps with the situation where the fd is larger than FD_MAXSIZE. Fixes #168
Use poll(2) instead of select(2) to do timeout operations on sockets. This helps with the situation where the fd is larger than FD_MAXSIZE. Fixes #168
I've merged in an implementation that uses |
Use poll(2) instead of select(2) to do timeout operations on sockets. This helps with the situation where the fd is larger than FD_MAXSIZE. Fixes alanxz#168
Use
poll()
instead ofselect()
when doing timeout operations on sockets in rabbitmq-c.The text was updated successfully, but these errors were encountered: