From 8c0adef6e74183c6b5cecd35db23dc9f2ca95f0a Mon Sep 17 00:00:00 2001 From: Marko Tiikkaja Date: Tue, 24 Jun 2014 13:49:20 +0200 Subject: [PATCH] Remove the old FIFO socket from the event queue when recreating it The previous code had two problems: 1) It never removed the old fd from the event loop, which meant that if the new fd received a different index, the old fd would keeping waking up the master process repeatedly. 2) If the new fd got the same index but the master loop went back to epoll_wait() fast enough, Linux would claim that the socket is ready for reading, but read() would return 0 again, which would cause the FIFO to be recreated again, etc. Fix by removing the old fd from the event queue before recreating it. --- core/fifo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/fifo.c b/core/fifo.c index 0ccfcc0c..19c7f0fc 100644 --- a/core/fifo.c +++ b/core/fifo.c @@ -131,6 +131,7 @@ int uwsgi_master_fifo_manage(int fd) { } // fifo destroyed, recreate it else if (rlen == 0) { + event_queue_del_fd(uwsgi.master_queue, uwsgi.master_fifo_fd, event_queue_read()); close(fd); uwsgi.master_fifo_fd = uwsgi_master_fifo(); event_queue_add_fd_read(uwsgi.master_queue, uwsgi.master_fifo_fd);