Created attachment 29768 [details] patch to check the return value and print the error setting Hi, In both mpm_event and mpm_worker, the error return of inappropriate ThreadStackSize setting is not checked and printed out. This brings difficult to users who wants to set small ThreadStackSize. In my case, I cannot easily know whether the my setting is accepted or not without any log message. The code is shown as follows: /* server/mpm/event/event.c server/mpm/worker/worker.c */ if (ap_thread_stacksize != 0) { apr_threadattr_stacksize_set(thread_attr, ap_thread_stacksize); } The return value of apr_threadattr_stacksize_set() tells whether the setting is valid or not. But the current code does not check the return value. I suggest to add a patch to check the return value and print out an error message, as follows (the patch is tested). if (ap_thread_stacksize != 0) { - rv = apr_threadattr_stacksize_set(thread_attr, ap_thread_stacksize); - if(rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING | APLOG_STARTUP, 0, NULL, APLOGNO(00522) - "WARNING: ThreadStackSize of %ld is inappropriate, change back to the default", - ap_thread_stacksize); - } + apr_threadattr_stacksize_set(thread_attr, ap_thread_stacksize); } The only thing I'm not sure is the APLOGNO. I don't know the rule of the number assignment. And it seems that adding a log message will break the sequential APLOGNO series.
Created attachment 29769 [details] patch to check the return value and print the error setting I update my patch. Thanks!
Created attachment 29770 [details] Please refer to this patch, thanks! Here is the correct one. I write it based on the SendBufferSize checker. The old patches are obsolete because it does not consider return value could be APR_ENOTIMPL. Please refer to this one. Thanks a lot! - apr_threadattr_stacksize_set(thread_attr, ap_thread_stacksize); + rv = apr_threadattr_stacksize_set(thread_attr, ap_thread_stacksize); + if(rv != APR_SUCCESS && rv != APR_ENOTIMPL) { + ap_log_error(APLOG_MARK, APLOG_WARNING | APLOG_STARTUP, 0, NULL, APLOGNO(00522) + "WARNING: ThreadStackSize of %ld is inappropriate, using default", + ap_thread_stacksize); + }
Thanks for the patch. Looks reasonable. Another place where the return value of 'apr_threadattr_stacksize_set' is not checked can be found on trunk in 'server/mpm/eventopt/eventopt.c' at line 2225
Thanks a lot, Christophe. But I don't find the file, i.e., 'server/mpm/eventopt/eventopt.c' in my source directory (actually I even don't have the eventopt directory). Is it new in trunk (compared with my stable version)?
Applied a slightly modified version to trunk. r1433682 If nobody complains, I'll propose it for backport in 2.4.x branch.
Proposed for backport to v2.4.
Backported to v2.4.5.