Enlightenment CVS committal Author : lordchaos Project : e17 Module : apps/efsd
Dir : e17/apps/efsd/efsd Modified Files: efsd.h efsd_commands.c efsd_commands.h efsd_io.c efsd_io.h efsd_main.c libefsd.c Log Message: Second batch of work on efsd/ecore_ipc. Working on get_filetype command for now, but once that works, everything else should be pretty generic. I went with transmitting a command over multiple ecore_ipc messages, rather than one big one, because it would result in more memory-alloc work on the client side to do it that way. This way is much faster, in my tests. Look in efsd_io.c, around line 878, and efsd_main near the top, to see how the ipc stuff is working =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- efsd.h 4 Aug 2005 05:30:22 -0000 1.23 +++ efsd.h 6 Aug 2005 08:43:21 -0000 1.24 @@ -25,6 +25,11 @@ #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> =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_commands.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- efsd_commands.c 6 Dec 2001 23:06:04 -0000 1.14 +++ efsd_commands.c 6 Aug 2005 08:43:21 -0000 1.15 @@ -26,6 +26,11 @@ # include <config.h> #endif +#if HAVE_ECORE +#include <Ecore.h> +#include <Ecore_Ipc.h> +#endif + #include <stdlib.h> #include <stdio.h> #include <errno.h> @@ -483,8 +488,14 @@ } +#if HAVE_ECORE +int +efsd_command_get_filetype(EfsdCommand *cmd, Ecore_Ipc_Client* client) +#else int efsd_command_get_filetype(EfsdCommand *cmd, int client) +#endif + { char type[MAXPATHLEN]; int result; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_commands.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- efsd_commands.h 26 Nov 2001 01:06:38 -0000 1.4 +++ efsd_commands.h 6 Aug 2005 08:43:21 -0000 1.5 @@ -42,6 +42,11 @@ int efsd_command_stop_monitor_metadata(EfsdCommand *cmd, int client); int efsd_command_stat(EfsdCommand *cmd, int client, char use_lstat); int efsd_command_readlink(EfsdCommand *cmd, int client); + +#if HAVE_ECORE +int efsd_command_get_filetype(EfsdCommand *cmd, Ecore_Ipc_Client* client); +#else int efsd_command_get_filetype(EfsdCommand *cmd, int client); +#endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_io.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -3 -r1.41 -r1.42 --- efsd_io.c 26 Nov 2001 01:06:38 -0000 1.41 +++ efsd_io.c 6 Aug 2005 08:43:21 -0000 1.42 @@ -842,12 +842,21 @@ /* Non-static stuff below: */ +#if HAVE_ECORE +efsd_io_write_command(Ecore_Ipc_Server* server, EfsdCommand *ec) +#else int efsd_io_write_command(int sockfd, EfsdCommand *ec) +#endif { + + + + EfsdIOV iov; struct msghdr msg; int n; + int i; D_ENTER; @@ -863,10 +872,28 @@ msg.msg_iov = iov.vec; msg.msg_iovlen = iov.v; + #if HAVE_ECORE + printf("ERR: ecore Sending command: efsd_io_write_command\n"); + + ecore_ipc_server_send(server, 1, 1, 0,0,0, &ec->type, sizeof(EfsdCommandType)); + ecore_ipc_server_send(server, 1, 2, 0,0,0, &ec->efsd_file_cmd.id, sizeof(EfsdCmdId)); + + for (i = 0; i < ec->efsd_file_cmd.num_files; i++) { + printf ("ERR: Writing filename %s\n", ec->efsd_file_cmd.files[i]); + ecore_ipc_server_send(server, 1, 3, 0,0,0, ec->efsd_file_cmd.files[i], strlen(ec->efsd_file_cmd.files[i]) + 1); /*Catch the \0*/ + } + + D_RETURN(0); + #else + + D_RETURN(0); if ((n = write_data(sockfd, &msg)) < 0) D_RETURN_(-1); D_RETURN_(0); + #endif + + } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_io.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- efsd_io.h 19 Mar 2001 18:12:33 -0000 1.4 +++ efsd_io.h 6 Aug 2005 08:43:22 -0000 1.5 @@ -27,7 +27,12 @@ #include <efsd.h> +#if HAVE_ECORE +int efsd_io_write_command(Ecore_Ipc_Server* server, EfsdCommand *ecom); +#else int efsd_io_write_command(int sockfd, EfsdCommand *ecom); +#endif + int efsd_io_read_command(int sockfd, EfsdCommand *ecom); int efsd_io_write_event(int sockfd, EfsdEvent *ee); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_main.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -3 -r1.55 -r1.56 --- efsd_main.c 4 Aug 2005 05:30:22 -0000 1.55 +++ efsd_main.c 6 Aug 2005 08:43:22 -0000 1.56 @@ -90,6 +90,10 @@ static char app_cmd[MAXPATHLEN]; static pid_t app_pid; +#if HAVE_ECORE +Ecore_Hash* partial_command_hash; /*The has we use to keep references to commands we're in the process of deserializing*/ +#endif + #if USE_THREADS #define EFSD_MAX_THREADS 50 @@ -105,14 +109,25 @@ typedef struct efsd_command_client_container { EfsdCommand *ecmd; + + #if HAVE_ECORE + Ecore_Ipc_Client* client; + #else int client; + #endif + char threaded; /* whether the contained command should be run in a thread or not */ } EfsdCommandClientContainer; /* Pthread wrappers to minimize #ifdef clutter */ +#if HAVE_ECORE +static void main_thread_launch(EfsdCommand *ecom, Ecore_Ipc_Client* client); +#else static void main_thread_launch(EfsdCommand *ecom, int client); +#endif + static void main_thread_detach(void); static void *main_handle_client_command(void *container); @@ -157,12 +172,60 @@ ipc_client_data(void *data, int type, void *event) { Ecore_Ipc_Event_Client_Data *e; + EfsdCommand* ec; - printf ("Got message!\n"); + printf ("ERR: Got message!\n"); if ((e = (Ecore_Ipc_Event_Client_Data *) event)) { - printf ("Got message!\n"); - ecore_ipc_client_send(e->client, 1, 6, e->ref, e->ref_to, 5, NULL, 0); + if (e->major == 1) { + /*ecore_ipc_client_send(e->client, 1, 6, e->ref, e->ref_to, 5, NULL, 0);*/ + /*main_thread_launch(e->data, e->client);*/ + + printf (" ERR: We have a command on our hands..\n"); + + if (e->minor == 1) { + printf(" ERR: Receiving command type, building a new EfsdCommand struct!\n"); + ec = NEW(EfsdCommand); + + ec->type = *(EfsdCommandType*)(e->data); + + printf (" ERR: Command type is %d\n", ec->type); + + ecore_hash_set(partial_command_hash, e->client, ec); + + } else if (e->minor == 2) { + printf(" ERR: Receiving a command id\n"); + + /*Retrieve the inprogress event*/ + ec = ecore_hash_get(partial_command_hash, e->client); + + printf (" ERR: Our in-progress command has type %d\n", ec->type); + + ec->efsd_file_cmd.id = *(EfsdCmdId*)(e->data); + + printf (" ERR: Received command id %d\n", ec->efsd_file_cmd.id); + + } else if (e->minor == 3) { + printf ( " ERR: Receiving a filename\n"); + + ec = ecore_hash_get(partial_command_hash, e->client); + + printf ("We have %d files so far..\n", ec->efsd_file_cmd.num_files); + + + if (!ec->efsd_file_cmd.num_files) { + ec->efsd_file_cmd.files = malloc(sizeof(char*)); + } else { + 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] = (char*)(e->data); + + printf ("Received a filename\n, it is '%s'\n", ec->efsd_file_cmd.files[ec->efsd_file_cmd.num_files]); + + ec->efsd_file_cmd.num_files+=1; + + } + } } } @@ -174,8 +237,14 @@ /* *********************************** */ -static void +#if HAVE_ECORE +static void +main_thread_launch(EfsdCommand *ecmd, Ecore_Ipc_Client* client) +#else +static void main_thread_launch(EfsdCommand *ecmd, int client) +#endif + { EfsdCommandClientContainer *container; @@ -712,11 +781,16 @@ static void main_handle_connections(void) { + int i; + + #if HAVE_ECORE + #else struct sockaddr_un serv_sun; - int num_read, fdsize, clilen, i, n, can_accept, sock_fd; + int num_read, fdsize, clilen, n, can_accept, sock_fd; fd_set fdrset; fd_set fdwset; fd_set *fdwset_ptr = NULL; + #endif char have_fam_thread = FALSE; struct timeval tv; int rebuild_fdset = FALSE; @@ -730,6 +804,7 @@ ev_q = efsd_queue_new(); + #ifndef HAVE_ECORE for (i = 0; i < EFSD_CLIENTS; i++) clientfd[i] = -1; @@ -756,6 +831,9 @@ fprintf(stderr, "Could not listen on socket -- exiting.\n"); exit(-1); } + #else + partial_command_hash = ecore_hash_new(ecore_direct_hash, ecore_direct_compare); + #endif #if USE_THREADS { @@ -1279,6 +1357,7 @@ #endif } + #ifndef HAVE_ECORE if (stat(efsd_misc_get_socket_file(), &st) >= 0) { if (opt_careful) @@ -1293,6 +1372,8 @@ exit(-1); } } + #endif + D_RETURN; } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/libefsd.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -3 -r1.57 -r1.58 --- libefsd.c 14 May 2002 09:46:18 -0000 1.57 +++ libefsd.c 6 Aug 2005 08:43:22 -0000 1.58 @@ -62,6 +62,10 @@ struct efsd_connection { + #if HAVE_ECORE + Ecore_Ipc_Server* server; + #endif + int fd; EfsdQueue *cmd_q; }; @@ -139,6 +143,8 @@ { D_ENTER; + printf("ERR: libefsd_send_command to ecore efsd_io_write_command\n"); + if (!ec || !com) D_RETURN_(-1); @@ -149,7 +155,14 @@ } else { - if (efsd_io_write_command(ec->fd, com) < 0) + if ( + #if HAVE_ECORE + + efsd_io_write_command(ec->server, com) < 0 + #else + efsd_io_write_command(ec->fd, com) < 0 + #endif + ) { if (errno == EPIPE) { @@ -192,6 +205,7 @@ for (i = 0, used_files = 0; i < num_files; i++) { full_files[used_files] = libefsd_get_full_path(files[i]); + printf("File with full path: %s\n", full_files[used_files]); if (full_files[used_files]) used_files++; } @@ -209,6 +223,7 @@ full_files = realloc(full_files, sizeof(char*) * used_files); } + printf("ERR: Libefsd file_cmd_absolute\n"); id = libefsd_file_cmd(ec, type, used_files, full_files, num_options, ops); D_RETURN_(id); @@ -243,6 +258,8 @@ } /* And send it! */ + + printf("ERR: Libefsd file_cmd\n"); if (libefsd_send_command(ec, &cmd) < 0) { efsd_cmd_cleanup(&cmd); @@ -334,7 +351,13 @@ while (!efsd_queue_empty(ec->cmd_q)) { cmd = (EfsdCommand*)efsd_queue_next_item(ec->cmd_q); - if (efsd_io_write_command(ec->fd, cmd) < 0) + if ( + #if HAVE_ECORE + efsd_io_write_command(ec->server, cmd) < 0 + #else + efsd_io_write_command(ec->fd, cmd) < 0 + #endif + ) { fprintf(stderr, "libefsd: queue NOT empty -- %i!\n", efsd_queue_size(ec->cmd_q)); D_RETURN; @@ -401,6 +424,15 @@ if (!ec) D_RETURN_(NULL); + #if HAVE_ECORE + + ec->server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, IPC_TITLE, 0, NULL); + if (!ec->server) { + fprintf(stderr, "libefsd: Ecore_Ipc error. Cannot see daemon\n"); + D_RETURN_(NULL); + } + + #else if ( (ec->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "libefsd: socket() error.\n"); D_RETURN_(NULL); @@ -426,6 +458,7 @@ fprintf(stderr, "Can not fcntl client's socket -- exiting.\n"); exit(-1); } + #endif ec->cmd_q = efsd_queue_new(); @@ -1194,6 +1227,7 @@ efsd_get_filetype(EfsdConnection *ec, char *filename) { D_ENTER; + printf("ERR: A call to get filetype with %s\n", filename); D_RETURN_(libefsd_file_cmd_absolute(ec, EFSD_CMD_GETFILETYPE, 1, &filename, 0, NULL)); } ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs