iterate clients fairly in clientsCron()#12025
Conversation
oranagra
left a comment
There was a problem hiding this comment.
I have some vague memory of some other piece of code that depended on that listRotateTailToHead call, possibly doing the counter rotation or putting things on one end due to that rotation, but i can't find that.
i guess that either this concern was already changed / dropped, or that i'm just mixing things up.
either way, this change seems safe to me.
I'm also worried about it, but I didn't find that code, we can merge it or wait more feedbacks? |
|
i think we can merge it.. we both reviewed this specific concern and didn't find any problems. |
|
i see in putClientInPendingWriteQueue, we always add the node (new client) to the head and in handleClientsWithPendingWrites, we process the list from head to tail will the order here cause problems? the new clients will be processed before old clients. |
|
why does it matter at which order we handle pending writes? |
|
new clients will be processed earlier than old clients, it is not FIFO. |
|
|
Every time when accept a connection, we add the client to
server.clientslist's tail, but inclientsCronwe rotate the tail to head at first, and then process the head. It means that the "new" client would be processed before "old" client, moreover if connections established and then freed frequently, the "old" client may have no chance to be processed.To fix it, we need take a fair way to iterate the list, that is take the current head and process, and then rotate the head to tail, thus we can make sure all clients could be processed step by step.
p.s. client has
client_list_nodepointer, we don't need put the current client to head to avoid O(N) when remove it.