| 1772 | } |
| 1773 | |
| 1774 | int freeClientsInAsyncFreeQueue(int iel) { |
| 1775 | serverAssert(GlobalLocksAcquired()); |
| 1776 | std::unique_lock<fastlock> ul(g_lockasyncfree); |
| 1777 | listIter li; |
| 1778 | listNode *ln; |
| 1779 | listRewind(g_pserver->clients_to_close,&li); |
| 1780 | |
| 1781 | // Store the clients in a temp vector since freeClient will modify this list |
| 1782 | std::vector<client*> vecclientsFree; |
| 1783 | while((ln = listNext(&li))) |
| 1784 | { |
| 1785 | client *c = (client*)listNodeValue(ln); |
| 1786 | if (c->iel == iel && !(c->flags & CLIENT_PROTECTED) && !c->casyncOpsPending) |
| 1787 | { |
| 1788 | vecclientsFree.push_back(c); |
| 1789 | listDelNode(g_pserver->clients_to_close, ln); |
| 1790 | } |
| 1791 | } |
| 1792 | ul.unlock(); |
| 1793 | |
| 1794 | for (client *c : vecclientsFree) |
| 1795 | { |
| 1796 | c->flags &= ~CLIENT_CLOSE_ASAP; |
| 1797 | freeClient(c); |
| 1798 | } |
| 1799 | return (int)vecclientsFree.size(); |
| 1800 | } |
| 1801 | |
| 1802 | /* Return a client by ID, or NULL if the client ID is not in the set |
| 1803 | * of registered clients. Note that "fake clients", created with -1 as FD, |
no test coverage detected