From: <enl...@li...> - 2005-08-10 23:59:39
|
Enlightenment CVS committal Author : lordchaos Project : e17 Module : apps/efsd Dir : e17/apps/efsd/efsd Modified Files: efsd.h efsd_io.c efsd_main.c efsd_meta_monitor.c efsd_meta_monitor.h efsd_monitor.c libefsd.c Log Message: Decided to require ecore. Live with it =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- efsd.h 8 Aug 2005 03:37:26 -0000 1.25 +++ efsd.h 10 Aug 2005 23:59:32 -0000 1.26 @@ -25,10 +25,8 @@ #ifndef efsd_h #define efsd_h -#if HAVE_ECORE #include <Ecore.h> #include <Ecore_Ipc.h> -#endif #include <sys/types.h> #include <sys/stat.h> @@ -265,6 +263,7 @@ #if HAVE_ECORE typedef struct ecore_ipc_message ecore_ipc_message; struct ecore_ipc_message { + int major; int minor; int ref; @@ -272,6 +271,10 @@ int response; void* data; int len; + + Ecore_Ipc_Client* client; + Ecore_Ipc_Client* server; + int dest; /*1 = client, 2=server*/ }; ecore_ipc_message* ecore_ipc_message_new(int major, int minor, int ref, int ref_to, int response, void* data, int len); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_io.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -3 -r1.50 -r1.51 --- efsd_io.c 9 Aug 2005 09:33:29 -0000 1.50 +++ efsd_io.c 10 Aug 2005 23:59:32 -0000 1.51 @@ -48,6 +48,14 @@ #include <efsd_misc.h> #include <efsd_io.h> +#if USE_THREADS +#include <efsd_lock.h> + +pthread_mutex_t queue_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +int msg_count; + /* The maximum number of data chunks (ints, char*s, void*s ...) a command/event consists of. Major laziness. */ @@ -71,7 +79,22 @@ } EfsdIOV; + +Ecore_List* process_queue = NULL; + #if HAVE_ECORE + +void ecore_ipc_client_message_queue(Ecore_Ipc_Client* client, ecore_ipc_message* message) { + LOCK(&queue_mutex); + + message->client = client; + ecore_list_goto_last(process_queue); + ecore_list_append(process_queue, message); + msg_count++; + UNLOCK(&queue_mutex); +} + + ecore_ipc_message* ecore_ipc_message_new(int major, int minor, int ref, int ref_to, int response, void* data, int len) { ecore_ipc_message* msg= malloc(sizeof(ecore_ipc_message)); @@ -82,6 +105,9 @@ msg->response = response; msg->data = data; msg->len = len; + msg->client=NULL; + msg->server=NULL; + msg->dest=0; return msg; } @@ -112,7 +138,7 @@ ec->efsd_file_cmd.files = realloc(ec->efsd_file_cmd.files, sizeof(char*) * (ec->efsd_file_cmd.num_files)+1); } ec->efsd_file_cmd.files[ec->efsd_file_cmd.num_files] = strdup(msg->data); - /*printf ("Received a filename\n, it is '%s'\n", ec->efsd_file_cmd.files[ec->efsd_file_cmd.num_files]);*/ + printf ("Received a filename\n, it is '%s'\n", msg->data); ec->efsd_file_cmd.num_files+=1; } else if (msg->minor == 4) { /*An efsdOption*/ @@ -775,6 +801,7 @@ D_ENTER; + printf ("Filling filechange event..\n"); el = ecore_list_new(); ecore_list_append(el, ecore_ipc_message_new(3, 1, 0,0,0,&ee->type, sizeof(EfsdEventType))); ecore_list_append(el, ecore_ipc_message_new(3, 2, 0,0,0,&ee->efsd_filechange_event.id, sizeof(EfsdCmdId))); @@ -802,7 +829,6 @@ - D_RETURN; } @@ -1177,13 +1203,20 @@ cmd = fill_event(ee); + printf("IPC writing evnet to client %p..\n", sockfd); /*Write these messages to the clients*/ ecore_list_goto_first(cmd); while ( (msg = ecore_list_next(cmd)) ) { - ecore_ipc_client_send(sockfd, msg->major, msg->minor, msg->ref, msg->ref_to, msg->response,msg->data, msg->len); + + printf ("Writing IPC message %p %d %d %d %d %d\n", sockfd, msg->major, msg->minor, msg->ref, msg->ref_to, msg->response); + ecore_ipc_client_message_queue(sockfd, msg); } - + printf("\n"); + ecore_list_destroy(cmd); + + + D_RETURN_(0); #else EfsdIOV iov; struct msghdr msg; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_main.c,v retrieving revision 1.60 retrieving revision 1.61 diff -u -3 -r1.60 -r1.61 --- efsd_main.c 9 Aug 2005 05:25:12 -0000 1.60 +++ efsd_main.c 10 Aug 2005 23:59:32 -0000 1.61 @@ -128,6 +128,8 @@ static void main_thread_launch(EfsdCommand *ecom, int client); #endif + + static void main_thread_detach(void); static void *main_handle_client_command(void *container); @@ -144,11 +146,45 @@ static void main_check_permissions(void); static void main_check_options(int argc, char**argv); +int queue_process_idler(void*); + +extern Ecore_List* process_queue; +extern pthread_mutex_t queue_mutex; +extern int msg_count=0; static Ecore_Ipc_Client* cl; /* *********************************** */ /* IPC Functions */ +int queue_process_idler(void* data) { + ecore_ipc_message* msg = NULL; + + + if (msg_count > 0) { + + LOCK(&queue_mutex); + + ecore_list_goto_first(process_queue); + msg = ecore_list_next(process_queue); + + if (msg) { + ecore_ipc_client_send(msg->client, msg->major, msg->minor, msg->ref, msg->ref_to, msg->response,msg->data, msg->len); + free(msg); + + ecore_list_remove_first(process_queue); + msg_count--; + } + + UNLOCK(&queue_mutex); + + } + + + return 1; +} + + + int ipc_client_add(void *data, int type, void *event) @@ -425,7 +461,7 @@ } ecore_hash_remove(partial_command_hash, client); - efsd_cmd_free(command); + /*efsd_cmd_free(command);*/ #if USE_THREADS if (container->threaded) @@ -693,7 +729,6 @@ efsd_stat_remove(famev_filename_canonical, TRUE); } - printf("Client is %p, internal is %p\n", emr->client, EFSD_CLIENT_INTERNAL); if (emr->client == EFSD_CLIENT_INTERNAL) { if ((famev.code == FAMChanged) || (famev.code == FAMCreated)) @@ -740,7 +775,6 @@ if (list_all_files || !efsd_misc_file_is_dotfile(famev.filename)) { printf("1\n"); - printf("Client is %p\n", emr->client); efsd_monitor_send_filechange_event(m, emr, famev.code, famev.filename); } } @@ -898,6 +932,10 @@ } + process_queue = ecore_list_new(); + + ecore_idler_add(&queue_process_idler, NULL); + ecore_main_loop_begin(); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_meta_monitor.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- efsd_meta_monitor.c 14 May 2002 09:46:18 -0000 1.3 +++ efsd_meta_monitor.c 10 Aug 2005 23:59:32 -0000 1.4 @@ -61,8 +61,8 @@ static EfsdMetaMonitor *meta_monitor_new(char *filename, char *key); static void meta_monitor_free(EfsdMetaMonitor *m); -static void meta_monitor_add_client(EfsdMetaMonitor *m, EfsdFileCmd *cmd, int client); -static void meta_monitor_del_client(EfsdMetaMonitor *m, int client, int do_lock); +static void meta_monitor_add_client(EfsdMetaMonitor *m, EfsdFileCmd *cmd, Ecore_Ipc_Client* client); +static void meta_monitor_del_client(EfsdMetaMonitor *m, Ecore_Ipc_Client* client, int do_lock); static EfsdMetaMonitor *meta_monitor_find(char *file, char *key); static void meta_monitor_get_key(char *file, char *key, char *result, int result_len); @@ -129,7 +129,7 @@ static void -meta_monitor_add_client(EfsdMetaMonitor *monitor, EfsdFileCmd *cmd, int client) +meta_monitor_add_client(EfsdMetaMonitor *monitor, EfsdFileCmd *cmd, Ecore_Ipc_Client* client) { EfsdList *l = NULL; EfsdMonitorRequest *emr = NULL; @@ -172,7 +172,7 @@ static void -meta_monitor_del_client(EfsdMetaMonitor *monitor, int client, int do_lock) +meta_monitor_del_client(EfsdMetaMonitor *monitor, Ecore_Ipc_Client* client, int do_lock) { EfsdList *l = NULL; EfsdMonitorRequest *emr = NULL; @@ -368,7 +368,7 @@ int -efsd_meta_monitor_add(EfsdCommand *cmd, int client) +efsd_meta_monitor_add(EfsdCommand *cmd, Ecore_Ipc_Client* client) { EfsdFileCmd *fcmd = NULL; EfsdMetaMonitor *monitor = NULL; @@ -411,7 +411,7 @@ int -efsd_meta_monitor_del(EfsdCommand *cmd, int client) +efsd_meta_monitor_del(EfsdCommand *cmd, Ecore_Ipc_Client* client) { EfsdFileCmd *fcmd = NULL; EfsdMetaMonitor *monitor = NULL; @@ -477,7 +477,7 @@ void -efsd_meta_monitor_cleanup_client(int client) +efsd_meta_monitor_cleanup_client(Ecore_Ipc_Client* client) { EfsdHashIterator *it; EfsdMetaMonitor *monitor; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_meta_monitor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- efsd_meta_monitor.h 26 Nov 2001 01:06:38 -0000 1.1 +++ efsd_meta_monitor.h 10 Aug 2005 23:59:32 -0000 1.2 @@ -49,7 +49,7 @@ * * Returns TRUE when successful, FALSE otherwise. */ -int efsd_meta_monitor_add(EfsdCommand *cmd, int client); +int efsd_meta_monitor_add(EfsdCommand *cmd, Ecore_Ipc_Client* client); /** @@ -65,7 +65,7 @@ * * Returns TRUE when successful, FALSE otherwise. */ -int efsd_meta_monitor_del(EfsdCommand *cmd, int client); +int efsd_meta_monitor_del(EfsdCommand *cmd, Ecore_Ipc_Client* client); /** * efsd_meta_monitor_notify - Reports changed metadata. @@ -89,6 +89,6 @@ * This function is called when the connection to a client ends. * It cleans up all monitors that this client had still registered. */ -void efsd_meta_monitor_cleanup_client(int client); +void efsd_meta_monitor_cleanup_client(Ecore_Ipc_Client* client); #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_monitor.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- efsd_monitor.c 9 Aug 2005 05:25:12 -0000 1.25 +++ efsd_monitor.c 10 Aug 2005 23:59:32 -0000 1.26 @@ -419,7 +419,6 @@ if (((EfsdMonitorRequest*)efsd_list_data(l))->client == client) { LOCK(&m->use_count_mutex); - printf("Client is %p, interal is %p\n", client, EFSD_CLIENT_INTERNAL); if (client == EFSD_CLIENT_INTERNAL) { =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/libefsd.c,v retrieving revision 1.65 retrieving revision 1.66 diff -u -3 -r1.65 -r1.66 --- libefsd.c 9 Aug 2005 09:33:29 -0000 1.65 +++ libefsd.c 10 Aug 2005 23:59:32 -0000 1.66 @@ -123,8 +123,6 @@ { Ecore_Ipc_Event_Server_Data *e; - /*printf("Received event from server..\n");*/ - fflush(stdout); if ((e = (Ecore_Ipc_Event_Server_Data *) event)) { @@ -139,9 +137,11 @@ msg->data = e->data; msg->len = e->size; + printf("MSG: %d %d %d %d %d\n", e->major, e->minor, e->ref, e->ref_to, e->response); + switch (e->major) { - case 1: /*printf("It's a command..\n");*/ + case 1: { ec = ecore_hash_get(partial_command_hash, e->server); @@ -156,6 +156,9 @@ deserialize_command(msg,ec); } else { /*printf("Command finished..processing..\n");*/ + + printf("Command filename: %s\n", ec->efsd_file_cmd.files[0]); + ec = ecore_hash_get(partial_command_hash, e->server); /*main_thread_launch(ec, e->client);*/ } @@ -166,12 +169,12 @@ break; case 2: - /*printf ("it's a reply event!\n");*/ event = ecore_hash_get(partial_event_hash, e->server); if (!event) { event = NEW(EfsdEvent); event->efsd_reply_event.data_len = 0; + event->efsd_reply_event.errorcode = 0; ecore_hash_set(partial_event_hash, e->server, event); } @@ -202,7 +205,7 @@ ecore_hash_remove(partial_event_hash, e->server); ecore_hash_remove(partial_command_hash, e->server); - printf("Command has %d files\n", event->efsd_reply_event.command.efsd_file_cmd.num_files); + /*printf("Command has %d files\n", event->efsd_reply_event.command.efsd_file_cmd.num_files);*/ /*printf("Filename is (from ec): %s\n", event->efsd_reply_event.command.efsd_file_cmd.files[0]);*/ @@ -217,11 +220,42 @@ break; case 3: - printf("It's a filechange event\n"); + + event = ecore_hash_get(partial_event_hash, e->server); + if (!event) { + event = NEW(EfsdEvent); + event->efsd_reply_event.data_len = 0; + event->efsd_reply_event.errorcode = 0; + + ecore_hash_set(partial_event_hash, e->server, event); + } switch (e->minor) { + case 1: /*EfsdEventType*/ + memcpy(&event->type, e->data, sizeof(EfsdEventType)); + break; + + case 2: /*EfsdCmdId*/ + memcpy(&event->efsd_filechange_event.id, e->data, sizeof(EfsdCmdId)); + break; + + case 3: /*EfsdFileChangeType*/ + memcpy(&event->efsd_filechange_event.changetype, e->data, sizeof(EfsdFilechangeType)); + break; + + case 4: + /*File*/ + event->efsd_filechange_event.file = strdup(e->data); + break; + + case 100: - printf("It's a terminate, we have all our data\n"); + + + ecore_hash_remove(partial_event_hash, e->server); + if (event_cb) { + (*event_cb)(event); + } break; } @@ -232,6 +266,8 @@ } + return 1; + } @@ -280,6 +316,7 @@ /*printf("ERR: libefsd_send_command to ecore efsd_io_write_command\n");*/ printf("Sending command..\n"); + fflush(stdout); D("Sending command..\n"); if (!ec || !com) |