]> git.sur5r.net Git - openldap/commitdiff
handle errors
authorPierangelo Masarati <ando@openldap.org>
Thu, 14 Sep 2006 19:55:52 +0000 (19:55 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 14 Sep 2006 19:55:52 +0000 (19:55 +0000)
servers/slapd/back-monitor/thread.c

index a7dbb5920a62344667c52d5a3d92879ab3a5ad39..5898070a62fdd86cf3a1016e66a121dbb4d88653 100644 (file)
@@ -129,13 +129,19 @@ monitor_subsys_thread_init(
                        break;
 
                case LDAP_PVT_THREAD_POOL_PARAM_STATE:
-                       ldap_pvt_thread_pool_query( &connection_pool,
-                               mt[ i ].param, (void *)&state );
-                       ber_str2bv( state, 0, 0, &bv );
+                       if ( ldap_pvt_thread_pool_query( &connection_pool,
+                               mt[ i ].param, (void *)&state ) == 0 )
+                       {
+                               ber_str2bv( state, 0, 0, &bv );
+
+                       } else {
+                               BER_BVSTR( &bv, "unknown" );
+                       }
                        break;
 
                default:
-                       ldap_pvt_thread_pool_query( &connection_pool,
+                       /* NOTE: in case of error, it'll be set to -1 */
+                       (void)ldap_pvt_thread_pool_query( &connection_pool,
                                mt[ i ].param, (void *)&count );
                        bv.bv_val = buf;
                        bv.bv_len = snprintf( buf, sizeof( buf ), "%d", count );
@@ -276,25 +282,27 @@ monitor_subsys_thread_update(
                if ( a == NULL ) {
                        return rs->sr_err = LDAP_OTHER;
                }
-               ldap_pvt_thread_pool_query( &connection_pool,
-                       mt[ i ].param, (void *)&state );
-               ber_str2bv( state, 0, 0, &bv );
-               ber_bvreplace( &a->a_vals[ 0 ], &bv );
+               if ( ldap_pvt_thread_pool_query( &connection_pool,
+                       mt[ i ].param, (void *)&state ) == 0 )
+               {
+                       ber_str2bv( state, 0, 0, &bv );
+                       ber_bvreplace( &a->a_vals[ 0 ], &bv );
+               }
                break;
 
        default:
                if ( a == NULL ) {
                        return rs->sr_err = LDAP_OTHER;
                }
-               ldap_pvt_thread_pool_query( &connection_pool,
-                       mt[ i ].param, (void *)&count );
-               bv.bv_val = buf;
-               bv.bv_len = snprintf( buf, sizeof( buf ), "%d", count );
-               if ( bv.bv_len >= sizeof( buf ) ) {
-                       /* FIXME? */
-                       break;
+               if ( ldap_pvt_thread_pool_query( &connection_pool,
+                       mt[ i ].param, (void *)&count ) == 0 )
+               {
+                       bv.bv_val = buf;
+                       bv.bv_len = snprintf( buf, sizeof( buf ), "%d", count );
+                       if ( bv.bv_len < sizeof( buf ) ) {
+                               ber_bvreplace( &a->a_vals[ 0 ], &bv );
+                       }
                }
-               ber_bvreplace( &a->a_vals[ 0 ], &bv );
                break;
        }