Changeset 1044

Show
Ignore:
Timestamp:
06/09/06 06:13:06 (2 years ago)
Author:
ehabkost
Message:

Use osync_queue_new_pipes() for commands_{to,from}_self

As pipes aren't opened with O_NONBLOCK, the engine can't open both sides
of the .opensync/engines/enginepipe pipe because it will keep waiting
for the other side to be opened.

But as the 'enginepipe' pipe is used only for the engine
sending messages to itself, osync_queue_new_pipes() fits
perfectly for this task.

This also makes the code simpler as it doesn't need to touch the
filesystem. At least for the 'enginepipe' queues -- the osplugin queues
still live in the filesystem.

Signed-off-by: Eduardo Habkost <ehabkost@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/ipc-branch/osengine/osengine_engine.c

    r1025 r1044  
    127127void send_engine_changed(OSyncEngine *engine) 
    128128{ 
     129        if (!engine->is_initialized) 
     130                return; 
     131 
    129132        OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_ENGINE_CHANGED, 0, NULL); 
    130133        /*FIXME: Handle errors here */ 
     
    517520        } 
    518521 
    519         engine->commands_from_self = osync_queue_new(path, error); 
    520         engine->commands_to_self = osync_queue_new(path, error); 
    521         if (!engine->commands_from_self || !engine->commands_to_self) 
    522                 goto error_free_paths; 
    523          
    524522        engine->syncing_mutex = g_mutex_new(); 
    525523        engine->info_received_mutex = g_mutex_new(); 
     
    790788        engine->is_initialized = TRUE; 
    791789         
    792         osync_queue_create(engine->commands_from_self, NULL); 
    793          
    794790        osync_trace(TRACE_INTERNAL, "Spawning clients"); 
    795791        GList *c = NULL; 
     
    815811        } 
    816812         
    817         osync_queue_set_message_handler(engine->commands_from_self, (OSyncMessageHandler)engine_message_handler, engine); 
    818         if (!(engine->man_dispatch)) 
    819                 osync_queue_setup_with_gmainloop(engine->commands_from_self, engine->context); 
    820          
    821813        osync_trace(TRACE_INTERNAL, "opening engine queue"); 
     814        if (!osync_queue_new_pipes(&engine->commands_from_self, &engine->commands_to_self, error)) { 
     815                osync_group_unlock(engine->group, TRUE); 
     816                osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); 
     817                return FALSE; 
     818        } 
     819 
    822820        if (!osync_queue_connect(engine->commands_from_self, OSYNC_QUEUE_RECEIVER, 0 )) { 
    823821                osync_group_unlock(engine->group, TRUE); 
     
    831829                return FALSE; 
    832830        } 
     831         
     832        osync_queue_set_message_handler(engine->commands_from_self, (OSyncMessageHandler)engine_message_handler, engine); 
     833        if (!(engine->man_dispatch)) 
     834                osync_queue_setup_with_gmainloop(engine->commands_from_self, engine->context); 
    833835         
    834836        osync_trace(TRACE_INTERNAL, "initializing clients");