]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix some contention issues under really high load...That doesn't mean you need to...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 7 Nov 2012 20:53:10 +0000 (14:53 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 7 Nov 2012 20:53:16 +0000 (14:53 -0600)
configure.in
libs/apr/.update
libs/apr/configure.in
libs/apr/threadproc/unix/thread.c
libs/sofia-sip/.update
libs/sofia-sip/configure.ac
libs/sofia-sip/libsofia-sip-ua/su/su_pthread_port.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index 1283b2a185a9de10e32d77d5f7cdeb1e46086428..821c939399db64b066df7033ad67c3db12da875d 100644 (file)
@@ -577,7 +577,7 @@ AX_HAVE_CPU_SET
 AC_CHECK_LIB(rt, clock_gettime, [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])])
 AC_CHECK_LIB(rt, clock_getres, [AC_DEFINE(HAVE_CLOCK_GETRES, 1, [Define if you have clock_getres()])])
 AC_CHECK_LIB(rt, clock_nanosleep, [AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define if you have clock_nanosleep()])])
-AC_CHECK_LIB(pthread, pthread_setschedprio, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1, [Define if you have pthread_setschedprio()])])
+AC_CHECK_LIB(pthread, pthread_setschedparam, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM, 1, [Define if you have pthread_setschedparam()])])
 
 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
 
index a55ae9a4f41db0a8f864b2a8961b71aa3ab04904..c106d5b06fbe8214c054187bfec1972a9025c1d7 100644 (file)
@@ -1 +1 @@
-Tue Oct 23 13:13:30 EDT 2012
+Wed Nov  7 10:37:54 CST 2012
index 412ee7e9372f1b15d13fea1884724b729cd012df..354fa772ba99923ae9f9247ac892118ee62cd08f 100644 (file)
@@ -1620,7 +1620,7 @@ APR_CHECK_DEFINE_FILES(POLLIN, poll.h sys/poll.h)
 if test "$threads" = "1"; then
     APR_CHECK_DEFINE(PTHREAD_PROCESS_SHARED, pthread.h)
     AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
-    AC_CHECK_LIB(pthread, pthread_setschedprio, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1, [Define if you have pthread_setschedprio()])])
+    AC_CHECK_LIB(pthread, pthread_setschedparam, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM, 1, [Define if you have pthread_setschedparam()])])
 
     # Some systems have setpshared and define PROCESS_SHARED, but don't 
     # really support PROCESS_SHARED locks.  So, we must validate that we 
index 391e5368c88d80a7c96eacae46d90f8f1a46e998..8859e79ac767e61a507073eb2f06a0f70443fd65 100644 (file)
@@ -146,6 +146,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
 {
     apr_status_t stat;
     pthread_attr_t *temp;
+       pthread_t tt;
 
     (*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));
 
@@ -173,15 +174,21 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
         return stat;
     }
 
-    if ((stat = pthread_create((*new)->td, temp, dummy_worker, (*new))) == 0) {
+    if ((stat = pthread_create(&tt, temp, dummy_worker, (*new))) == 0) {
 
-#ifdef HAVE_PTHREAD_SETSCHEDPRIO
+#ifdef HAVE_PTHREAD_SETSCHEDPARAM
                if (attr && attr->priority) {
-                       pthread_t *thread = (*new)->td;
-                       pthread_setschedprio(*thread, attr->priority);
+                       int policy;
+                       struct sched_param param = { 0 };
+
+                       pthread_getschedparam(tt, &policy, &param);
+                       param.sched_priority = attr->priority;
+                       pthread_setschedparam(tt, policy, &param);
                }
 #endif
 
+               *(*new)->td = tt;
+
         return APR_SUCCESS;
     }
     else {
index 09f61c0ed459fdf23fcb3f7ccf38173903fc2802..5f4122980545b557714871cb58088a3d3b047065 100644 (file)
@@ -1 +1 @@
-Fri Nov  2 13:36:06 CDT 2012
+Wed Nov  7 10:37:42 CST 2012
index 1bce33e178ad41835dd38b3a63b54359f301d9d8..f882bc76b424f297320f10bc9f784241d7447bf3 100644 (file)
@@ -254,7 +254,7 @@ if test x"$have_check" = "xyes"; then
 fi
 AC_CHECK_HEADERS([fnmatch.h])
 
-AC_CHECK_LIB(pthread, pthread_setschedprio, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1, [Define if you have pthread_setschedprio()])])
+AC_CHECK_LIB(pthread, pthread_setschedparam, [AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM, 1, [Define if you have pthread_setschedparam()])])
 
 
 dnl dl is currently used only in testing
index 5eb391f38d62028c7cc3ef9103111c6f1328a2e1..d20eb709bd8d29c73167aee1d892980ea334879e 100644 (file)
@@ -268,9 +268,13 @@ int su_pthreaded_port_start(su_port_create_f *create,
 
   pthread_mutex_lock(arg.mutex);
   if (pthread_create(&tid, &attr, su_pthread_port_clone_main, &arg) == 0) {
+#ifdef HAVE_PTHREAD_SETSCHEDPARAM
+         int policy;
+         struct sched_param param;
 
-#ifdef HAVE_PTHREAD_SETSCHEDPRIO
-         pthread_setschedprio(tid, 99);
+         pthread_getschedparam(tid, &policy, &param);
+         param.sched_priority = 99;
+         pthread_setschedparam(tid, policy, &param);
 #endif
 
     pthread_cond_wait(arg.cv, arg.mutex);
index 7e55407962a776bbf662013cb054ea609ac01686..cf89cba93cf64a970d8623b5647ec8ca1a9ccdc2 100644 (file)
@@ -6532,6 +6532,9 @@ char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex
 
        switch_cache_db_release_db_handle(&dbh);
 
+
+       sofia_glue_fire_events(profile);
+
        return ret;
 }
 
@@ -7159,6 +7162,23 @@ void sofia_event_fire(sofia_profile_t *profile, switch_event_t **event)
        *event = NULL;
 }
 
+void sofia_glue_fire_events(sofia_profile_t *profile)
+{
+       void *pop = NULL;
+
+       while (profile->event_queue && switch_queue_trypop(profile->event_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
+               switch_event_t *event = (switch_event_t *) pop;
+               switch_event_fire(&event);
+       }
+
+}
+
+void sofia_event_fire(sofia_profile_t *profile, switch_event_t **event)
+{
+       switch_queue_push(profile->event_queue, *event);
+       *event = NULL;
+}
+
 
 /* For Emacs:
  * Local Variables: