rpms/bind/devel bind-9.3.1-dbus_restart.patch, NONE, 1.1 bind.spec, 1.72, 1.73
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Thu Oct 6 01:27:15 UTC 2005
- Previous message (by thread): rpms/anaconda/devel .cvsignore, 1.145, 1.146 anaconda.spec, 1.261, 1.262 sources, 1.263, 1.264
- Next message (by thread): rpms/gnome-mag/devel .cvsignore, 1.14, 1.15 gnome-mag.spec, 1.17, 1.18 sources, 1.14, 1.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: jvdias
Update of /cvs/dist/rpms/bind/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv13161
Modified Files:
bind.spec
Added Files:
bind-9.3.1-dbus_restart.patch
Log Message:
fix dbus re-connect on dbus-daemon restart
bind-9.3.1-dbus_restart.patch:
dbus_mgr.c | 70 ++-
dbus_service.c | 923 ++++++-------------------------------------
include/named/dbus_service.h | 86 ----
3 files changed, 203 insertions(+), 876 deletions(-)
--- NEW FILE bind-9.3.1-dbus_restart.patch ---
--- bind-9.3.1/bin/named/dbus_service.c.dbus_restart 2005-10-05 19:31:08.000000000 -0400
+++ bind-9.3.1/bin/named/dbus_service.c 2005-10-05 19:41:02.000000000 -0400
@@ -2,8 +2,8 @@
*
* D-BUS Service Utilities
*
- * Provides utilities for construction of D-BUS "Services"
- *
+ * Provides MINIMAL utilities for construction of D-BUS "Services".
+ *
* Jason Vas Dias <jvdias at redhat.com>, Red Hat Inc., 2005
*/
@@ -119,647 +119,6 @@
);
}
-static int root_comparator( const void *p1, const void *p2)
-{
- return strcmp((const char*)(((const Root*)p1)->path),
- (const char*)(((const Root*)p2)->path)
- );
-}
-
-static int mh_comparator( const void *p1, const void *p2 )
-{
- return strcmp((const char*)(((const MessageHandlerNode*)p1)->path),
- (const char*)(((const MessageHandlerNode*)p2)->path)
- );
-}
-
-static int mf_comparator( const void *p1, const void *p2 )
-{
- return ptr_key_comparator( (const void*)(((const MessageFilterNode*)p1)->mf),
- (const void*)(((const MessageFilterNode*)p2)->mf)
- );
-}
-
-static void
-unregister_function (DBusConnection *connection, void *user_data)
-{
- connection = user_data = 0L;
-}
-
-static DBusHandlerResult
-message_handler
-( DBusConnection *connection,
- DBusMessage *message,
- void *user_data
-)
-{
- Root *root = user_data;
- DBusConnectionState* cs = root->cs;
- uint32_t type =dbus_message_get_type( message ),
- serial =dbus_message_get_serial( message );
- uint8_t reply =(dbus_message_get_no_reply( message )==0);
- const char
- *path = dbus_message_get_path( message ),
- *dest = dbus_message_get_destination( message ),
- *member = dbus_message_get_member( message ),
- *interface=dbus_message_get_interface( message ),
- *sender =dbus_message_get_sender( message ),
- *signature=dbus_message_get_signature( message ),
- *if_suffix=0L,
- *obj_suffix=0L;
- char
- sub_path[1024];
- MessageHandlerNode mhn, *mhp, **mhpp;
- dbus_svc_HandlerResult r;
- int len;
- connection = connection;
- if( cs->dh != 0L ) (*(cs->dh))("message_handler : dest:%s path:%s member:%s interface:%s",
- dest, path, member, interface
- );
- if( path == 0L )
- {
- if( cs->eh != 0L ) (*(cs->eh))("message_handler: message with NULL path");
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- if(( root->if_prefix != 0L ) && (interface != 0L))
- {
- len = strlen(root->if_prefix);
- if( (strncmp(interface, root->if_prefix, len) == 0) && (interface[len] == '.'))
- if_suffix = interface + len + 1;
- }
-
- r = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- if ( strcmp(path, root->path) == 0 )
- {
- r = ( (*(root->mh))
- ( cs, type, reply, serial, dest, path, member, interface, if_suffix,
- sender, signature, message,
- 0L, 0L, 0L, root->object
- )
- );
- if( r != HANDLED_NOW )
- return r;
- }
-
- if ( root->tree == 0L )
- {
- if( cs->eh != 0L ) (*(cs->eh))("message_handler: not a prefix");
- return r;
- }
-
- len = strlen(root->path);
- if( ((int)strlen(path) < len) || (strncmp(root->path, path, len) != 0) )
- {
- if( cs->eh != 0L ) (*(cs->eh))("message_handler: can't happen?!?: path %s not prefixed by %s",
- path, root->path
- );
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- obj_suffix = (path + len + 1);
-
- if( root->tree == root )
- { /* no sub-path handlers defined yet */
- r = ( (*(root->mh))
- ( cs, type, reply, serial, dest, path, member, interface, if_suffix,
- sender, signature, message,
- root->path, obj_suffix, 0L, root->object
- )
- );
- if( r != HANDLED_NOW )
- return r;
- }
-
- if( root->tree != root )
- {
- if( ( if_suffix != 0L ) && (member != 0L) )
- {
- snprintf(sub_path, 1024, "%s.%s.%s",
- obj_suffix, if_suffix, member
- );
- }else
- if( (if_suffix == 0L) && (member != 0L))
- {
- snprintf(sub_path, 1024, "%s.%s",
- obj_suffix, member
- );
- }else
- if( member != 0L)
- {
- snprintf(sub_path, 1024, "%s.%s",
- obj_suffix, member
- );
- }else
- {
- if( cs->eh != 0L ) (*(cs->eh))("message_handler: null member for %s", path);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- if( cs->dh != 0L ) (*(cs->dh))("message_handler: looking up sub-path %s", sub_path);
-
- mhn.path=(char*)sub_path;
- mhpp = tfind(&mhn, &(root->tree), mh_comparator);
-
- if ( (mhpp == 0L) || ((mhp=*mhpp)==0L) )
- {
- r = ( (*(root->mh))
- ( cs, type, reply, serial, dest, path, member, interface, if_suffix,
- sender, signature, message,
- root->path, obj_suffix, 0L, root->object
- )
- );
- if( r != HANDLED_NOW )
- return r;
- mhpp = tfind(&mhn, &(root->tree), mh_comparator);
- if ( (mhpp == 0L) || ((mhp=*mhpp)==0L) )
- {
- if( cs->eh != 0L ) (*(cs->eh))("message_handler: message handler not found under %s for sub-path %s", path, sub_path);
-
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
- }
- r =( (*(mhp->mh))
- ( cs, type, reply, serial, dest, path, member, interface, if_suffix,
- sender, signature, message,
- root->path, obj_suffix, root->object, mhp->object
- )
- );
- if( r == HANDLED_NOW )
- {
- mhn.path=(char*)sub_path;
- mhpp = tfind(&mhn, &(root->tree), mh_comparator);
- if ( (mhpp == 0L) || ((mhp=*mhpp)==0L) )
- {
- if( cs->eh != 0L ) (*(cs->eh))("message_handler: message handler returned HANDLED_NOW for unhandled path %s", sub_path);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
- r =
- ( (*(mhp->mh))
- ( cs, type, reply, serial, dest, path, member, interface, if_suffix,
- sender, signature, message,
- root->path, obj_suffix, root->object, mhp->object
- )
- );
- }else
- return r;
- }
-
- /* obj.if.member lookup failed */
-
- if( cs->dh != 0L ) (*(cs->dh))("message_handler: message handler not found for sub-path %s", obj_suffix);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static DBusHandlerResult
-default_message_handler
-( DBusConnection *connection,
- DBusMessage *message,
- void *user_data
-)
-{
- DBusConnectionState* cs = user_data;
- uint32_t type =dbus_message_get_type( message ),
- serial =dbus_message_get_serial( message );
- uint8_t reply =(dbus_message_get_no_reply( message )==0);
- const char
- *path = dbus_message_get_path( message ),
- *dest = dbus_message_get_destination( message ),
- *member = dbus_message_get_member( message ),
- *interface=dbus_message_get_interface( message ),
- *sender =dbus_message_get_sender( message ),
- *signature=dbus_message_get_signature( message );
- connection = connection;
- return
- (*(cs->mh))
- ( cs, type, reply, serial, dest, path, member, interface, 0L,
- sender, signature, message,
- 0L, 0L, 0L, cs->def_mh_obj
- );
-}
-
-uint8_t
-dbus_svc_add_default_handler
-( DBusConnectionState *cs, char *object_path, dbus_svc_MessageHandler mh, void *object
-)
-{
- DBusObjectPathVTable vtable = { unregister_function, default_message_handler, NULL, 0, 0, 0 };
- cs->mh = mh;
- cs->def_mh_obj = object;
- return dbus_connection_register_fallback
- ( cs->connection,
- object_path,
- &vtable,
- cs
- );
-}
-
-uint8_t
-dbus_svc_add_path_handler
-( DBusConnectionState* cs,
- char *rootPath,
- char *ifPrefix,
- dbus_svc_MessageHandler mh,
- void *object,
- uint8_t isPrefix
-)
-{
- DBusObjectPathVTable vtable = { unregister_function, message_handler, NULL, 0, 0, 0 };
- Root *root;
- char *path, *ifp=0L;
-
- if( (rootPath == 0L) || (*rootPath == '\0') || (*rootPath != '/') )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_message_handler: invalid path %s", rootPath);
- return ( 0 );
- }
-
- root = ( Root* ) malloc( sizeof(Root) );
- path = ( char* ) malloc( strlen(rootPath) + 1 );
-
- if ( ( path == 0L ) || ( root == 0L ) )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_path_handler: out of memory");
- return(0);
- }
- if( ifPrefix != 0L )
- {
- if((ifp = (char*)malloc(strlen(ifPrefix)+1))==0L)
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_path_handler: out of memory");
- return(0);
- }
- strcpy(ifp, ifPrefix);
- }
- strcpy(path, rootPath);
- root->cs = cs;
- root->path = path;
- root->if_prefix = ifp;
- root->mh = mh;
- root->tree = isPrefix ? root : 0L;
- root->object = object;
-
- if ( ( (!isPrefix) &&
- !dbus_connection_register_object_path
- ( cs->connection,
- rootPath,
- &vtable,
- root
- )
- )
- ||( isPrefix &&
- !dbus_connection_register_fallback
- ( cs->connection,
- rootPath,
- &vtable,
- root
- )
- )
- )
- {
- if( cs->eh != 0L ) (*(cs->eh))
- ( "dbus_svc_add_message_handler failed for: %s: %s", rootPath,
- isPrefix ? "dbus_connection_register_fallback failed"
- : "dbus_connection_register_object_path failed"
- );
- return ( 0 );
- }
-
- return ( tsearch( root, &(cs->roots), root_comparator ) != 0L );
-}
-
-void free_mh( void *);
-void free_mh( void *mp )
-{
- MessageHandlerNode *mh = mp;
- free(mh->path);
- free(mh);
-}
-
-uint8_t
-dbus_svc_remove_path_handler
-(
- DBusConnectionState *cs,
- char *rootPath ,
- void **objectP
-)
-{
- Root r;
- Root *root, *const*rpp;
-
- if ( ( rootPath == 0L ) || ( *rootPath ='\0') || (*rootPath != '/'))
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_remove_path: bad root path %s", rootPath);
- return 0;
- }
-
- r.path = rootPath;
-
- rpp = tfind( &r, &(cs->roots), root_comparator );
-
- if ( (rpp = 0L) || ( (root=*rpp) == 0L ) )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_remove_path_handler: cannot remove nonexistent root node %s", rootPath);
- return 0;
- }
-
- tdelete(root, &(cs->roots), root_comparator);
-
- if ( !dbus_connection_unregister_object_path( cs->connection, rootPath ) )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_remove_path_handler:"
- "dbus_connection_unregister_object_path failed"
- );
- return ( 0 );
- }
-
- if ( ( root->tree != root ) && (root->tree != 0L) )
- tdestroy(root->tree, free_mh);
-
- if ( ( objectP != 0L ) && ( root->object != 0L ))
- *objectP = root->object;
-
- free(root->path);
- free((Root*)root);
-
- return 1;
-}
-
-static uint8_t
-add_handler
-( DBusConnectionState* cs,
- Root *root,
- char *path,
- dbus_svc_MessageHandler mh,
- void *object
-)
-{
- MessageHandlerNode *mhn = (MessageHandlerNode*) malloc ( sizeof(MessageHandlerNode) );
-
- if ( mhn == 0L )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_message_handler: out of memory");
- return ( 0 );
- }
-
- mhn->mh = mh;
-
- mhn->path = (char*) malloc (strlen(path)+1);
-
- strcpy(mhn->path,path);
-
- mhn->object = object;
-
- if( root->tree == root )
- root->tree = 0L;
- return ( tsearch( (void*)mhn , &(root->tree), mh_comparator ) != 0);
-}
-
-static Root*
-find_root
-( DBusConnectionState *cs,
- char *rootPath
-)
-{
- Root r;
- Root *root, *const*rpp;
-
- if( (rootPath == 0L) || (*rootPath=='\0') )
- return 0L;
-
- r.path=rootPath;
-
- rpp = tfind(&r, &(cs->roots), root_comparator);
-
- if ( (rpp==0L) || ((root=*rpp) == 0L ) )
- return 0L;
- return (Root*)root;
-}
-
-uint8_t
-dbus_svc_add_handler
-( DBusConnectionState *cs,
- char *rootPath,
- char *objectPath,
- dbus_svc_MessageHandler mh,
- void *object
-)
-{
- Root *root = find_root(cs, rootPath);
- int len;
-
- if( (root == 0L) || (objectPath==0L) || (*objectPath=='\0') )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_handler: bad path %s/%s", rootPath, objectPath);
- return 0;
- }
-
- len = strlen(root->path);
-
- if ( strncmp(root->path, objectPath, len) == 0 )
- {
- if ( *(objectPath + len)=='\0' )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_handler: cannot add object path %s - identical to prefix path", objectPath);
- return( 0 );
- }else
- if ( (*(objectPath + len)=='/' )
- &&(*(objectPath + len + 1) != '\0')
- &&(*(objectPath + len + 1) != '/')
- )
- {
- (*cs->eh)("dbus_svc_add_handler: invalid object path %s", (objectPath + len));
- return 0;
- }else
- if ( *(objectPath + len)!='/' )
- {
- (*cs->eh)("dbus_svc_add_handler: invalid object path %s", (objectPath + len));
- return 0;
- }
- objectPath += len + 1;
- }else
- if ( *objectPath == '/' )
- {
- if ( (*(objectPath+1) == '\0')
- ||(*(objectPath+1) == '/')
- )
- {
- (*cs->eh)("dbus_svc_add_handler: invalid object path %s", objectPath );
- return 0;
- }
- objectPath += 1;
- }else
- if ( *objectPath == '\0' )
- {
- (*cs->eh)("dbus_svc_add_handler: empty object path");
- return 0;
- }
-
- return( add_handler(cs, root, objectPath, mh, object) != 0L);
-}
-
-uint8_t
-dbus_svc_remove_handler
-( DBusConnectionState* cs ,
- char *rootPath,
- char *objectPath,
- void **objectP
-)
-{
- MessageHandlerNode mh, *mhp, **mhpp;
- Root *root = find_root(cs, rootPath);
-
- if( ( root == 0L ) || (objectPath == 0L) || (*objectPath=='\0') )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_remove_handler: unhandled path %s/%s", rootPath, objectPath);
- return( 0 );
- }
-
- mh.path = objectPath;
-
- if ( root->tree == root )
- return 0;
-
- mhpp = tfind(&mh, &(root->tree), mh_comparator);
-
- if( (mhpp != 0L) && ((mhp = *mhpp) != 0L) )
- {
- mhpp = tdelete(&mh, &(root->tree), mh_comparator);
- free(mhp->path);
- if( objectP != 0L )
- *objectP = mhp->object;
- free(mhp);
- }
-
- return (mhpp != 0L);
-}
-
-static void
-filter_current_message( const void *p, const VISIT which, const int level)
-{
- MessageFilterNode *mfp;
- MessageFilterNode *const*mfpp = p;
- int l = level ? 1 : 0;
- l=l;
-
- if( (mfpp == 0L) || ((mfp=*mfpp)==0L)
- || ((which != postorder) && (which != leaf))
- )
- return;
- if( mfp->cs->rejectMessage )
- return;
-
- DBusMessage *message = mfp->cs->currentMessage;
- uint32_t type =dbus_message_get_type( message ),
- serial =dbus_message_get_serial( message );
- uint8_t reply =dbus_message_get_no_reply( message )==0;
- const char
- *path = dbus_message_get_path( message ),
- *dest = dbus_message_get_destination( message ),
- *member = dbus_message_get_member( message ),
- *interface=dbus_message_get_interface( message ),
- *sender =dbus_message_get_sender( message ),
- *signature=dbus_message_get_signature( message );
- char
- *if_suffix=0L;
- mfp->cs->rejectMessage =
- ( (*(mfp->mf))
- ( mfp->cs, type, reply, serial, dest, path, member, interface, if_suffix,
- sender, signature, message, 0L, 0L, 0L, mfp->obj
- ) == HANDLED
- );
-}
-
-static DBusHandlerResult
-message_filter (DBusConnection *connection,
- DBusMessage *message,
- void *p
- )
-{
- DBusConnectionState *cs = p;
- connection=connection;
-
- cs->currentMessage = message;
- cs->rejectMessage = 0;
-
- twalk( cs->filters, filter_current_message);
-
- cs->currentMessage=0L;
- if( cs->rejectMessage )
- {
- cs->rejectMessage = 0;
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-uint8_t
-dbus_svc_add_message_filter
-( DBusConnectionState *cs, dbus_svc_MessageHandler mf, void *obj, int n_matches, ... )
-{
- MessageFilterNode *mfn;
- char **mp,*m;
- DBusError error;
- va_list va;
-
- va_start(va, n_matches );
-
- if ( ! dbus_connection_add_filter (cs->connection, message_filter, cs, NULL))
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_message_filter: dbus_connection_add_filter failed");
- va_end(va);
- return( 0 );
- }
- mfn = (MessageFilterNode *) malloc( sizeof( MessageFilterNode ) );
- if( mfn == 0L )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_message_filter: out of memory");
- va_end(va);
- return( 0 );
- }
- mfn->mf = mf;
- mfn->cs = cs;
- mfn->obj = obj;
- mfn->n_matches = n_matches;
- mfn->matches = 0L;
- if( n_matches )
- {
- memset(&error,'\0',sizeof(DBusError));
- dbus_error_init(&error);
- if((mp = mfn->matches = (char**)calloc(n_matches + 1, sizeof(char*)))==0L)
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_message_filter: out of memory");
- va_end(va);
- return( 0 );
- }
- while( n_matches-- )
- {
- m = va_arg(va, char* ) ;
- if( (*mp = (char*)malloc(strlen(m)+1)) == 0L )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_message_filter: out of memory");
- va_end(va);
- return(0);
- }
- strcpy(*mp, m);
- dbus_bus_add_match(cs->connection, *mp, &error);
- if( dbus_error_is_set(&error))
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_add_message_filter: dbus_bus_add_match failed for %s: %s %s",
- *mp, error.name, error.message
- );
- va_end(va);
- return(0);
- }
- mp++;
- }
- }
- va_end(va);
- return (tsearch(mfn, &(cs->filters), mf_comparator) != 0L);
-}
-
-
static DBusHandlerResult
default_message_filter
( DBusConnection *connection,
@@ -830,78 +189,6 @@
return( 1 );
}
-uint8_t
-dbus_svc_remove_message_filter( DBusConnectionState *cs, dbus_svc_MessageHandler mf )
-{
- MessageFilterNode **mfpp = tfind( mf, &(cs->filters), ptr_key_comparator), *mfp;
- DBusError error;
- int i;
-
- if( (mfpp != 0L) && ((mfp=*mfpp) !=0L) )
- {
- mfpp = tdelete(mfp->mf,&(cs->filters),mf_comparator);
- if(mfp->n_matches)
- {
- memset(&error,'\0',sizeof(DBusError));
- dbus_error_init(&error);
- for( i=0; i < mfp->n_matches; i++)
- {
- dbus_bus_remove_match(cs->connection, mfp->matches[i], &error);
- if( dbus_error_is_set(&error) )
- {
- if( cs->eh != 0L ) (*(cs->eh))("dbus_svc_remove_message_filter: remove match failed: %s %s",
- error.name, error.message
- );
- } /*XXX fixme: what if other handlers still want to match this match exp.?*/
- }
- free(mfp->matches);
- }
- free(mfp);
- }
- if( (mfpp != 0L) && (cs->filters == 0L) )
- dbus_connection_remove_filter (cs->connection, message_filter, cs);
- return (mfpp != 0);
-}
-
-
-static DBusHandlerResult
-shutdown_filter
-( DBusConnection *connection,
- DBusMessage *message,
- void *p
-)
-{
- DBusConnectionState *cs = p;
- uint32_t type =dbus_message_get_type( message );
- const char
- *path = dbus_message_get_path( message ),
- *member = dbus_message_get_member( message );
- connection=connection;
-
- if ( ( type == SIGNAL )
- &&( strcmp(path,"/org/freedesktop/DBus/Local") == 0 )
- &&( strcmp(member,"Disconnected") == 0 )
- )
- {
- if(cs->eh) (*(cs->eh))("D-BUS Shutdown");
- if( cs->sh )
- (*(cs->sh))(cs, cs->sh_obj);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- if(cs->eh) (*(cs->eh))("D-BUS message not filtered %s %s", path, member);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-uint8_t
-dbus_svc_add_shutdown_filter
-(
- DBusConnectionState *cs, dbus_svc_ShutdownHandler sh, void *obj
-)
-{
- cs->sh = sh;
- cs->sh_obj = obj;
- return dbus_connection_add_filter( cs->connection, shutdown_filter, cs, NULL );
-}
uint8_t
dbus_svc_get_args_va(DBusConnectionState *cs, DBusMessage* msg, dbus_svc_DataType firstType, va_list va)
@@ -1479,6 +766,8 @@
FD_CLR(fd , &(cs->r_fds));
FD_CLR(fd , &(cs->w_fds));
FD_CLR(fd , &(cs->e_fds));
+ if( cs->wh != 0L )
+ (*(cs->wh))(dbus_watch_get_fd(watch), WATCH_READ | WATCH_WRITE | WATCH_ERROR, cs->wh_arg );
}
static void
@@ -1556,6 +845,63 @@
cs->dispatchStatus = new_status;
}
+void
+dbus_svc_main_loop( DBusConnectionState *cs, void (*idle_handler)(DBusConnectionState *) )
+{
+ struct timeval timeout={0,200000};
+ int n_fds;
+
+ while( cs->status != SHUTDOWN )
+ {
+ cs->s_r_fds = cs->r_fds;
+ cs->s_w_fds = cs->w_fds;
+ cs->s_e_fds = cs->e_fds;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec= 200000;
+
+ if ( (n_fds = select(cs->n, &(cs->s_r_fds), &(cs->s_w_fds), &(cs->s_e_fds), &timeout)) < 0 )
+ {
+ if (errno != EINTR)
+ {
+ if( cs->eh != 0L ) (*(cs->eh))( "select failed: %d : %s", errno, strerror(errno));
+ return;
+ }
+ }
+
+ if( n_fds > 0 )
+ process_watches(cs);
+
+ process_timeouts(cs);
+
+ if ( cs->dispatchStatus != DBUS_DISPATCH_COMPLETE )
+ dbus_connection_dispatch( cs->connection );
+
+ if( idle_handler != 0L )
+ (*idle_handler)(cs);
+ }
+}
+
+void dbus_svc_dispatch(DBusConnectionState *cs)
+{
+ process_watches(cs);
+
+ FD_ZERO(&(cs->s_r_fds));
+ FD_ZERO(&(cs->s_w_fds));
+ FD_ZERO(&(cs->s_e_fds));
+
+ process_timeouts(cs);
+
+ while ( cs->dispatchStatus != DBUS_DISPATCH_COMPLETE )
+ dbus_connection_dispatch( cs->connection );
+}
+
+void
+dbus_svc_quit( DBusConnectionState *cs )
+{
+ cs->status = SHUTDOWN;
+}
+
static DBusConnectionState *
connection_setup
( DBusConnection *connection,
@@ -1628,63 +974,6 @@
return 0L;
}
-void
-dbus_svc_main_loop( DBusConnectionState *cs, void (*idle_handler)(DBusConnectionState *) )
-{
- struct timeval timeout={0,200000};
- int n_fds;
-
- while( cs->status != SHUTDOWN )
- {
- cs->s_r_fds = cs->r_fds;
- cs->s_w_fds = cs->w_fds;
- cs->s_e_fds = cs->e_fds;
-
- timeout.tv_sec = 0;
- timeout.tv_usec= 200000;
-
- if ( (n_fds = select(cs->n, &(cs->s_r_fds), &(cs->s_w_fds), &(cs->s_e_fds), &timeout)) < 0 )
- {
- if (errno != EINTR)
- {
- if( cs->eh != 0L ) (*(cs->eh))( "select failed: %d : %s", errno, strerror(errno));
- return;
- }
- }
-
- if( n_fds > 0 )
- process_watches(cs);
-
- process_timeouts(cs);
-
- if ( cs->dispatchStatus != DBUS_DISPATCH_COMPLETE )
- dbus_connection_dispatch( cs->connection );
-
- if( idle_handler != 0L )
- (*idle_handler)(cs);
- }
-}
-
-void dbus_svc_dispatch(DBusConnectionState *cs)
-{
- process_watches(cs);
-
- FD_ZERO(&(cs->s_r_fds));
- FD_ZERO(&(cs->s_w_fds));
- FD_ZERO(&(cs->s_e_fds));
-
- process_timeouts(cs);
-
- while ( cs->dispatchStatus != DBUS_DISPATCH_COMPLETE )
- dbus_connection_dispatch( cs->connection );
-}
-
-void
-dbus_svc_quit( DBusConnectionState *cs )
-{
- cs->status = SHUTDOWN;
-}
-
DBusConnectionState *
dbus_svc_init
(
@@ -1699,17 +988,72 @@
DBusConnection *connection;
DBusError error;
DBusConnectionState *cs;
-
+ char *session_bus_address=0L;
+
memset(&error,'\0',sizeof(DBusError));
dbus_error_init(&error);
- if ( (connection = dbus_bus_get (bus, &error)) == 0L )
+ switch( bus )
{
- if(eh)(*eh)("dbus_svc_init failed: %s %s",error.name, error.message);
+ /* DBUS_PRIVATE_* bus types are the only type which allow reconnection if the dbus-daemon is restarted
+ */
+ case DBUS_PRIVATE_SYSTEM:
+
+ if ( (connection = dbus_connection_open_private("unix:path=/var/run/dbus/system_bus_socket", &error)) == 0L )
+ {
+ if(eh)(*eh)("dbus_svc_init failed: %s %s",error.name, error.message);
+ return ( 0L );
+ }
+
+ if ( ! dbus_bus_register(connection,&error) )
+ {
+ if(eh)(*eh)("dbus_bus_register failed: %s %s", error.name, error.message);
+ dbus_connection_close(connection);
+ free(connection);
+ return ( 0L );
+ }
+ break;
+
+ case DBUS_PRIVATE_SESSION:
+
+ session_bus_address = getenv("DBUS_SESSION_BUS_ADDRESS");
+ if ( session_bus_address == 0L )
+ {
+ if(eh)(*eh)("dbus_svc_init failed: DBUS_SESSION_BUS_ADDRESS environment variable not set");
+ return ( 0L );
+ }
+
+ if ( (connection = dbus_connection_open_private(session_bus_address, &error)) == 0L )
+ {
+ if(eh)(*eh)("dbus_svc_init failed: %s %s",error.name, error.message);
+ return ( 0L );
+ }
+
+ if ( ! dbus_bus_register(connection,&error) )
+ {
+ if(eh)(*eh)("dbus_bus_register failed: %s %s", error.name, error.message);
+ dbus_connection_close(connection);
+ free(connection);
+ return ( 0L );
+ }
+ break;
+
+ case DBUS_SYSTEM:
+ case DBUS_SESSION:
+
+ if ( (connection = dbus_bus_get (bus, &error)) == 0L )
+ {
+ if(eh)(*eh)("dbus_svc_init failed: %s %s",error.name, error.message);
+ return ( 0L );
+ }
+ break;
+
+ default:
+ if(eh)(*eh)("dbus_svc_init failed: unknown bus type %d", bus);
return ( 0L );
}
-
+
dbus_connection_set_exit_on_disconnect(connection, FALSE);
if ( (cs = connection_setup(connection, wh, eh, dh, wh_arg)) == 0L )
@@ -1720,7 +1064,7 @@
if( name == 0L )
return( cs );
-
+
cs->unique_name = dbus_bus_get_unique_name(connection);
switch
@@ -1740,12 +1084,18 @@
if(eh)(*eh)("dbus_svc_init: dbus_bus_request_name failed: %s %s", error.name, error.message);
goto give_up;
}
-
return ( cs );
give_up:
- dbus_connection_disconnect( connection );
+ dbus_connection_close( connection );
dbus_connection_unref( connection );
+ if( cs )
+ {
+ dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL);
+ dbus_connection_set_watch_functions (connection, NULL, NULL, NULL, NULL, NULL);
+ dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL);
+ free(cs);
+ }
return ( 0L );
}
@@ -1754,16 +1104,6 @@
return cs->unique_name;
}
-static
-void free_root( void *rp )
-{
- Root *root = rp;
- if( root->tree != root )
- tdestroy(root->tree, free_mh);
- free(root->path);
- free(root);
-}
-
void
dbus_svc_shutdown ( DBusConnectionState *cs )
{
@@ -1789,11 +1129,8 @@
cs->timeouts=0L;
tdestroy( cs->watches, no_free);
cs->watches=0L;
- tdestroy( cs->roots, free_root);
- cs->roots=0L;
-
- dbus_connection_disconnect( cs->connection );
+ dbus_connection_close( cs->connection );
dbus_connection_unref( cs->connection );
free( cs );
--- bind-9.3.1/bin/named/include/named/dbus_service.h.dbus_restart 2005-10-05 19:31:08.000000000 -0400
+++ bind-9.3.1/bin/named/include/named/dbus_service.h 2005-10-05 18:51:32.000000000 -0400
@@ -25,7 +25,9 @@
{
DBUS_SESSION,
DBUS_SYSTEM,
- DBUS_STARTER
+ DBUS_STARTER,
+ DBUS_PRIVATE_SYSTEM,
+ DBUS_PRIVATE_SESSION
} dbus_svc_DBUS_TYPE;
typedef enum /* D-BUS Protocol Type Codes / Signature Chars */
@@ -131,6 +133,14 @@
* call dbus_svc_dispatch when all watches have been handled.
*/
+
+uint8_t
+dbus_svc_add_filter
+( DBUS_SVC, dbus_svc_MessageHandler mh, void *obj, int n_matches, ... );
+/*
+ * Registers SINGLE message handler to handle ALL messages, adding match rules
+ */
+
void dbus_svc_main_loop( DBUS_SVC, void (*idle_handler)(DBUS_SVC) );
void dbus_svc_handle_watch( DBUS_SVC, int watch_fd, dbus_svc_WatchFlags action);
@@ -159,59 +169,6 @@
*/
uint8_t
-dbus_svc_add_path_handler
-( DBUS_SVC, char *rootPath, char *ifPrefix, dbus_svc_MessageHandler mh, void *object, uint8_t isPrefix
-);
-/*
- * Registers message handler with D-BUS to handle all messages sent
- * to rootPath root Object Path.
- * If isPrefix > 1, this path may prefix other handled paths; ie.
- * a "Fallback" handler is registered, and when a message is sent
- * to a path prefixed by the rootPath, if no sub-path handler has been
- * registered with "dbus_svc_add_handler", the message-handler is called
- * with "prefix" non-null, and "path" set to the suffix (sub-path); otherwise
- * the sub-path handler is called.
- * Cannot be used in conjunction with dbus_svc_add_default_handler .
- */
-
-uint8_t
-dbus_svc_add_default_handler
-( DBUS_SVC, char *object_path, dbus_svc_MessageHandler mh, void *object
-);
-/* Registers the single default Fallback handler to handle all messages.
- * Cannot be used in conjunction with dbus_svc_add_path_handler / dbus_svc_add_handler.
- */
-
-uint8_t
-dbus_svc_add_handler( DBUS_SVC, char *rootPath, char *objectPath, dbus_svc_MessageHandler mh, void *object );
-/*
- * Registers with the 'dbus_svc' module a sub-path handler for objectPath prefixed by
- * an existing rootPath registered with dbus_svc_add_path_handler. The registered
- * handler will be called with "path" set to the complete path, "prefix" set to the
- * prefix portion, "suffix" set to the suffix, "object" set to the this registered
- * object pointer, and "prefixObject" set to the object registered for the prefix path.
- */
-
-uint8_t
-dbus_svc_remove_path_handler
-( DBUS_SVC,
- char *rootPath ,
- void **objectP
-);
-/* Removes the root Object Path handler and unregisters it with D-BUS.
- * All sub-path handlers for this path are also removed.
- * If objectP is non-null, the address of the object stored with dbus_svc_add_path_handler
- * will be stored in it.
- */
-
-uint8_t
-dbus_svc_remove_handler
-( DBUS_SVC, char *rootPath, char *objectPath, void **objectP );
-/* Removes sub-path handler for objectPath under rootPath
- * and returns stored object in *objectP if not null.
- */
-
-uint8_t
dbus_svc_get_args( DBUS_SVC, dbus_svc_MessageHandle, dbus_svc_DataType, ... );
/* get arguments from message */
@@ -219,27 +176,6 @@
dbus_svc_get_args_va( DBUS_SVC, dbus_svc_MessageHandle, dbus_svc_DataType, va_list );
/* get arguments from message */
-uint8_t
-dbus_svc_remove_message_handler
-( DBUS_SVC, char *objectPath );
-/* Unregisters the message handler */
-
-uint8_t
-dbus_svc_add_message_filter
-( DBUS_SVC, dbus_svc_MessageHandler mh, void *obj, int n_matches, ... );
-/*
- * Registers message handler to FILTER all messages sent to objectPath
- * before they are Handled.
- * If n_matches is > 0, then the variable argument list can contain n_matches
- * "const char*"s that are "match expressions" to pass to dbus_bus_add_match()
- */
-
-uint8_t
-dbus_svc_add_filter
-( DBUS_SVC, dbus_svc_MessageHandler mh, void *obj, int n_matches, ... );
-/*
- * Registers SINGLE message handler to handle ALL messages, adding match rules
- */
typedef void (*dbus_svc_ShutdownHandler) ( DBUS_SVC, void * );
uint8_t
--- bind-9.3.1/bin/named/dbus_mgr.c.dbus_restart 2005-10-05 19:31:08.000000000 -0400
+++ bind-9.3.1/bin/named/dbus_mgr.c 2005-10-05 21:00:51.000000000 -0400
@@ -194,6 +194,21 @@
return 0;
}
+static
+int dbus_mgr_log_info( const char *fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ isc_log_vwrite(ns_g_lctx,
+ NS_LOGCATEGORY_DBUS,
+ NS_LOGMODULE_DBUS,
+ ISC_LOG_DEBUG(1),
+ fmt, va
+ );
+ va_end(va);
+ return 0;
+}
+
isc_result_t
dbus_mgr_create
( isc_mem_t *mctx,
@@ -258,6 +273,7 @@
if( mgr->sockets != 0L )
{
+ isc_task_purgerange(mgr->task, 0L, ISC_SOCKEVENT_READ_READY, ISC_SOCKEVENT_SELECTED, 0L);
twalk(mgr->sockets, dbus_mgr_close_socket);
tdestroy(mgr->sockets, dbus_mgr_destroy_socket);
mgr->sockets = 0L;
@@ -271,7 +287,7 @@
mgr->dbus =
dbus_svc_init
- ( DBUS_SYSTEM,
+ ( DBUS_PRIVATE_SYSTEM,
destination,
dbus_mgr_watch_handler,
0L, 0L,
@@ -282,7 +298,6 @@
{
if( mgr->timer == 0L)
{
- dbus_mgr_log_err("D-BUS service disabled.");
isc_task_purgerange(mgr->task, 0L, ISC_SOCKEVENT_READ_READY, ISC_SOCKEVENT_SELECTED, 0L);
if( mgr->sockets != 0L )
{
@@ -326,7 +341,7 @@
return ISC_R_SUCCESS;
cleanup:
-
+ isc_task_purgerange(mgr->task, 0L, ISC_SOCKEVENT_READ_READY, ISC_SOCKEVENT_SELECTED, 0L);
twalk(mgr->sockets, dbus_mgr_close_socket);
tdestroy(mgr->sockets, dbus_mgr_destroy_socket);
mgr->sockets = 0L;
@@ -411,6 +426,7 @@
isc_timer_detach(&(mgr->timer));
if( mgr->dbus != 0L )
{
+ isc_task_purgerange(mgr->task, 0L, ISC_SOCKEVENT_READ_READY, ISC_SOCKEVENT_SELECTED, 0L);
if( mgr->sockets != 0L )
{
twalk(mgr->sockets, dbus_mgr_close_socket);
@@ -434,6 +450,7 @@
ns_dbus_mgr_t *mgr = (ns_dbus_mgr_t*)(ev->ev_arg) ;
t=t;
isc_event_free(&ev);
+ dbus_mgr_log_dbg("attempting to connect to D-BUS");
dbus_mgr_init_dbus( mgr );
}
@@ -452,6 +469,7 @@
if ( dbus != 0L )
{
+ isc_task_purgerange(mgr->task, 0L, ISC_SOCKEVENT_READ_READY, ISC_SOCKEVENT_SELECTED, 0L);
if( mgr->sockets != 0L )
{
twalk(mgr->sockets, dbus_mgr_close_socket);
@@ -498,8 +516,10 @@
sizeof(isc_event_t)
);
if( dbus_shutdown_event != 0L )
+ {
+ isc_task_purgerange(mgr->task, 0L, ISC_SOCKEVENT_READ_READY, ISC_SOCKEVENT_SELECTED, 0L);
isc_task_send( mgr->task, &dbus_shutdown_event );
- else
+ }else
dbus_mgr_log_err("unable to allocate dbus shutdown event");
}
@@ -652,6 +672,23 @@
mgr->ifwdt = 0L;
}
+static void
+dbus_mgr_log_forwarders( const char *pfx, dns_name_t *name, SockAddrList *saList)
+{
+ isc_sockaddr_t *sa;
+ char nameP[DNS_NAME_FORMATSIZE], addrP[128];
+ int s=0;
+ dns_name_format(name, nameP, DNS_NAME_FORMATSIZE );
+ for( sa = ISC_LIST_HEAD(*saList);
+ sa != 0L;
+ sa = ISC_LIST_NEXT(sa,link)
+ )
+ {
+ isc_sockaddr_format(sa, addrP, 128);
+ dbus_mgr_log_info("%s zone %s server %d: %s", pfx, nameP, s++, addrP);
+ }
+}
+
static
isc_result_t dbus_mgr_set_forwarders
(
@@ -667,7 +704,7 @@
dns_name_t *dnsName;
isc_sockaddr_t *sa, *nsa;
dns_forwarders_t *fwdr=0L;
-
+
fwdtable = dbus_mgr_get_view_and_fwdtable(&view);
if( fwdtable == 0L )
@@ -690,8 +727,12 @@
if( result != ISC_R_SUCCESS )
return result;
+
if( view->fwdtable == 0L )
return ISC_R_NOMEMORY;
+
+ if( isc_log_getdebuglevel(ns_g_lctx) >= 1 )
+ dbus_mgr_log_info("Created forwarder table.");
}
}
@@ -725,6 +766,9 @@
if( result != ISC_R_SUCCESS )
return result;
+
+ if( isc_log_getdebuglevel(ns_g_lctx) >= 1 )
+ dbus_mgr_log_forwarders("Created forwarder",dnsName, saList);
}
continue;
}
@@ -732,6 +776,9 @@
if( ISC_LIST_HEAD( *saList ) == 0L )
{ /* empty forwarders list - delete forwarder entry */
+ if( isc_log_getdebuglevel(ns_g_lctx) >= 1 )
+ dbus_mgr_log_forwarders("Deleting forwarder", dnsName, (SockAddrList*)&(fwdr->addrs));
+
result = isc_task_beginexclusive(mgr->task);
if( result == ISC_R_SUCCESS )
{
@@ -743,7 +790,7 @@
isc_task_endexclusive(mgr->task);
if( result != ISC_R_SUCCESS )
- return result;
+ return result;
}
continue;
}
@@ -753,6 +800,9 @@
if( result == ISC_R_SUCCESS )
{
fwdr->fwdpolicy = fwdpolicy;
+
+ if( isc_log_getdebuglevel(ns_g_lctx) >= 1 )
+ dbus_mgr_log_forwarders("Removing forwarder", dnsName, (SockAddrList*)&(fwdr->addrs));
for( sa = ISC_LIST_HEAD(fwdr->addrs);
sa != 0L ;
@@ -787,6 +837,9 @@
isc_task_endexclusive(mgr->task);
+ if( isc_log_getdebuglevel(ns_g_lctx) >= 1 )
+ dbus_mgr_log_forwarders("Added forwarder", dnsName, (SockAddrList*)&(fwdr->addrs));
+
}else
return result;
@@ -1092,7 +1145,7 @@
isc_sockaddr_t *nsSA;
isc_result_t result;
uint8_t fwdpolicy = dns_fwdpolicy_only;
-
+
iter = dbus_svc_message_iterator_new( dbus, msg );
if( iter == 0L )
@@ -2292,6 +2345,7 @@
}
}else
{
+ dbus_mgr_log_dbg("watch %d disabled",fd);
if(flags & WATCH_READ)
{
sev = isc_socket_fd_handle_reads( sfd->sock, 0L );
@@ -2326,7 +2380,7 @@
tdelete(sfd, &(mgr->sockets), dbus_mgr_socket_comparator);
- isc_mem_put(mgr->mctx, sfd, sizeof(sfd));
+ isc_mem_put(mgr->mctx, sfd, sizeof(DBusMgrSocket));
}
}
}
Index: bind.spec
===================================================================
RCS file: /cvs/dist/rpms/bind/devel/bind.spec,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- bind.spec 27 Sep 2005 18:15:59 -0000 1.72
+++ bind.spec 6 Oct 2005 01:27:12 -0000 1.73
@@ -10,7 +10,7 @@
Name: bind
License: BSD-like
Version: 9.3.1
-Release: 14
+Release: 16
Epoch: 24
Url: http://www.isc.org/products/BIND/
Buildroot: %{_tmppath}/%{name}-root
@@ -57,6 +57,7 @@
Patch24: bind-9.3.1-t_no_default_lookups.patch
Patch25: bind-9.3.1-fix_no_dbus_daemon.patch
Patch26: bind-9.3.1-flush-cache.patch
+Patch27: bind-9.3.1-dbus_restart.patch
Requires(pre,preun): shadow-utils
Requires(post,preun): chkconfig
Requires(post): textutils, fileutils, sed, grep
@@ -226,6 +227,7 @@
%patch24 -p1 -b .-t_no_default_lookups
%patch25 -p1 -b .fix_no_dbus_daemon
%patch26 -p1 -b .flush_cache
+%patch27 -p1 -b .dbus_restart
%build
libtoolize --copy --force; aclocal; autoconf
cp -f /usr/share/libtool/config.{guess,sub} .
@@ -717,6 +719,9 @@
:;
%changelog
+* Wed Oct 05 2005 Jason Vas Dias <jvdias at redhat.com> - 24:9.3.1-16
+- Fix reconnecting to dbus-daemon after it stops & restarts .
+
* Tue Sep 27 2005 Jason Vas Dias <jvdias at redhat.com> - 24:9.3.1-14
- When forwarder nameservers are changed with D-BUS, flush the cache.
- Previous message (by thread): rpms/anaconda/devel .cvsignore, 1.145, 1.146 anaconda.spec, 1.261, 1.262 sources, 1.263, 1.264
- Next message (by thread): rpms/gnome-mag/devel .cvsignore, 1.14, 1.15 gnome-mag.spec, 1.17, 1.18 sources, 1.14, 1.15
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-cvs-commits
mailing list