| 2647 | } |
| 2648 | |
| 2649 | static int updateMaxclients(long long val, long long prev, const char **err) { |
| 2650 | /* Try to check if the OS is capable of supporting so many FDs. */ |
| 2651 | if (val > prev) { |
| 2652 | adjustOpenFilesLimit(); |
| 2653 | if (g_pserver->maxclients != val) { |
| 2654 | static char msg[128]; |
| 2655 | snprintf(msg, sizeof(msg), "The operating system is not able to handle the specified number of clients, try with %d", g_pserver->maxclients); |
| 2656 | *err = msg; |
| 2657 | if (g_pserver->maxclients > prev) { |
| 2658 | g_pserver->maxclients = prev; |
| 2659 | adjustOpenFilesLimit(); |
| 2660 | } |
| 2661 | return 0; |
| 2662 | } |
| 2663 | /* Change the SetSize for the current thread first. If any error, return the error message to the client, |
| 2664 | * otherwise, continue to do the same for other threads */ |
| 2665 | if ((unsigned int) aeGetSetSize(aeGetCurrentEventLoop()) < |
| 2666 | g_pserver->maxclients + CONFIG_FDSET_INCR) |
| 2667 | { |
| 2668 | if (aeResizeSetSize(aeGetCurrentEventLoop(), |
| 2669 | g_pserver->maxclients + CONFIG_FDSET_INCR) == AE_ERR) |
| 2670 | { |
| 2671 | *err = "The event loop API used by KeyDB is not able to handle the specified number of clients"; |
| 2672 | return 0; |
| 2673 | } |
| 2674 | serverLog(LL_DEBUG,"Successfully changed the setsize for current thread %d", ielFromEventLoop(aeGetCurrentEventLoop())); |
| 2675 | } |
| 2676 | |
| 2677 | for (int iel = 0; iel < cserver.cthreads; ++iel) |
| 2678 | { |
| 2679 | if (g_pserver->rgthreadvar[iel].el == aeGetCurrentEventLoop()){ |
| 2680 | continue; |
| 2681 | } |
| 2682 | |
| 2683 | if ((unsigned int) aeGetSetSize(g_pserver->rgthreadvar[iel].el) < |
| 2684 | g_pserver->maxclients + CONFIG_FDSET_INCR) |
| 2685 | { |
| 2686 | int res = aePostFunction(g_pserver->rgthreadvar[iel].el, [iel] { |
| 2687 | if (aeResizeSetSize(g_pserver->rgthreadvar[iel].el, g_pserver->maxclients + CONFIG_FDSET_INCR) == AE_ERR) { |
| 2688 | serverLog(LL_WARNING,"Failed to change the setsize for Thread %d", iel); |
| 2689 | } |
| 2690 | }); |
| 2691 | |
| 2692 | if (res != AE_OK){ |
| 2693 | static char msg[128]; |
| 2694 | snprintf(msg, sizeof(msg),"Failed to post the request to change setsize for Thread %d", iel); |
| 2695 | *err = msg; |
| 2696 | return 0; |
| 2697 | } |
| 2698 | serverLog(LL_DEBUG,"Successfully post the request to change the setsize for thread %d", iel); |
| 2699 | } |
| 2700 | } |
| 2701 | } |
| 2702 | return 1; |
| 2703 | } |
| 2704 | |
| 2705 | static int validateMultiMasterNoForward(int val, const char **) { |
| 2706 | if (val) { |
nothing calls this directly
no test coverage detected