Changeset 2526
- Timestamp:
- 09/25/07 20:04:09 (10 months ago)
- Files:
-
- trunk/opensync/client/opensync_client.c (modified) (2 diffs)
- trunk/opensync/client/opensync_client_proxy.c (modified) (16 diffs)
- trunk/opensync/client/osplugin.c (modified) (1 diff)
- trunk/opensync/group/opensync_member_internals.h (modified) (1 diff)
- trunk/opensync/ipc/opensync_message.c (modified) (1 diff)
- trunk/opensync/ipc/opensync_message.h (modified) (1 diff)
- trunk/opensync/ipc/opensync_queue.c (modified) (3 diffs)
- trunk/opensync/plugin/opensync_plugin_internals.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/opensync/client/opensync_client.c
r2368 r2526 1059 1059 OSyncError *error = NULL; 1060 1060 1061 osync_trace(TRACE_INTERNAL, "plugin received command %i ", osync_message_get_command(message));1061 osync_trace(TRACE_INTERNAL, "plugin received command %i (%s)", osync_message_get_command(message), osync_message_get_commandstr(message)); 1062 1062 1063 1063 switch (osync_message_get_command(message)) { … … 1263 1263 osync_queue_free(client->outgoing); 1264 1264 } 1265 1265 1266 1266 if (client->plugin) 1267 1267 osync_plugin_unref(client->plugin); trunk/opensync/client/opensync_client_proxy.c
r2525 r2526 40 40 #ifdef _WIN32 41 41 /* Historical signals specified by POSIX. */ 42 #define SIGKILL 9 /* Kill (cannot be blocked, caught, or ignored). */42 #define SIGKILL 9 /* Kill (cannot be blocked, caught, or ignored). */ 43 43 #define SIGTERM 15 /* can be caught and interpreted or ignored by the process */ 44 44 #endif //_WIN32 … … 79 79 80 80 //portable kill pid helper 81 #if 0 82 static int _osync_kill(pid_t pid, int sig) 81 /*static int _osync_kill(pid_t pid, int sig) 83 82 { 84 83 #ifndef _WIN32 … … 107 106 return (ret); 108 107 #endif //_WIN32 109 } 110 #endif 111 112 #if 0 113 static char *_osync_client_pid_filename(OSyncClientProxy *proxy) 108 }*/ 109 110 /*static char *_osync_client_pid_filename(OSyncClientProxy *proxy) 114 111 { 115 112 return g_strdup_printf("%s/osplugin.pid", proxy->path); 116 } 117 118 static osync_bool osync_client_remove_pidfile(OSyncClientProxy *proxy, OSyncError **error)113 }*/ 114 115 /*static osync_bool osync_client_remove_pidfile(OSyncClientProxy *proxy, OSyncError **error) 119 116 { 120 117 char *pidpath = _osync_client_pid_filename(proxy); … … 128 125 g_free(pidpath); 129 126 return TRUE; 130 } 131 132 static osync_bool _osync_client_create_pidfile(OSyncClientProxy *proxy, OSyncError **error)127 }*/ 128 129 /*static osync_bool _osync_client_create_pidfile(OSyncClientProxy *proxy, OSyncError **error) 133 130 { 134 131 char *pidpath = _osync_client_pid_filename(proxy); … … 144 141 g_free(pidpath); 145 142 return TRUE; 146 } 147 148 static osync_bool _osync_client_kill_old_osplugin(OSyncClientProxy *proxy, OSyncError **error)143 }*/ 144 145 /*static osync_bool _osync_client_kill_old_osplugin(OSyncClientProxy *proxy, OSyncError **error) 149 146 { 150 147 osync_bool ret = FALSE; … … 156 153 char *pidpath = _osync_client_pid_filename(proxy); 157 154 158 / * Simply returns if there is no PID file */155 // Simply returns if there is no PID file 159 156 if (!g_file_test(pidpath, G_FILE_TEST_EXISTS)) { 160 157 ret = TRUE; … … 173 170 if (_osync_kill(pid, SIGTERM) < 0) { 174 171 osync_trace(TRACE_INTERNAL, "Error killing old osplugin: %s. Stale pid file?", g_strerror(errno)); 175 / * Don't return failure if kill() failed, because it may be a stale pid file */172 // Don't return failure if kill() failed, because it may be a stale pid file 176 173 } 177 174 … … 184 181 } 185 182 osync_trace(TRACE_INTERNAL, "Waiting for other side to terminate"); 186 / *FIXME: Magic numbers are evil */183 // FIXME: Magic numbers are evil 187 184 g_usleep(500000); 188 185 } … … 193 190 } 194 191 195 / * Success */192 // Success 196 193 ret = TRUE; 197 194 … … 202 199 //out: 203 200 return ret; 204 } 205 #endif 201 }*/ 202 206 203 207 204 /** This function takes care of the messages received on the outgoing (sending) … … 807 804 proxy->outgoing = write1; 808 805 proxy->incoming = read2; 809 806 810 807 /* Now we either spawn a new process, or we create a new thread */ 811 808 if (type == OSYNC_START_TYPE_THREAD) { … … 830 827 } else { 831 828 /* First lets see if the old plugin exists, and kill it if it does */ 832 #if 0 833 if (!_osync_client_kill_old_osplugin(proxy, error)) 834 goto error; 835 #endif 836 829 //if (!_osync_client_kill_old_osplugin(proxy, error)) 830 // goto error; 831 832 //if (!osync_queue_exists(proxy->outgoing) || !osync_queue_is_alive(proxy->outgoing)) { 837 833 if (!proxy->outgoing || !osync_queue_exists(proxy->outgoing) || !osync_queue_is_alive(proxy->outgoing)) { 838 834 pid_t cpid = fork(); 839 835 if (cpid == 0) { 840 836 osync_trace_reset_indent(); 837 841 838 /* close the read and write ends of the pipes */ 842 839 osync_queue_disconnect(write1, error); 843 840 osync_queue_disconnect(read2, error); 844 845 osync_trace_reset_indent(); 846 841 842 osync_trace(TRACE_INTERNAL, "About to exec osplugin"); 843 //char *memberstring = g_strdup_printf("%lli", osync_member_get_id(proxy->member)); 844 //execlp("osplugin", "osplugin", osync_group_get_configdir(osync_member_get_group(osync_proxy_get_member(proxy)), memberstring, NULL); 847 845 char *readfd = g_strdup_printf("%i", osync_queue_get_fd(read1)); 848 846 char *writefd = g_strdup_printf("%i", osync_queue_get_fd(write2)); 849 850 osync_trace(TRACE_INTERNAL, "About to exec osplugin"); 851 execlp("osplugin", "osplugin", "-f", readfd, writefd, NULL); 852 847 execlp("osplugin", "osplugin", "-f", readfd, writefd, NULL); 848 853 849 if (errno == ENOENT) { 854 850 osync_trace(TRACE_INTERNAL, "Unable to find osplugin. Trying local path."); 851 //execlp("osplugin", "osplugin", osync_group_get_configdir(osync_member_get_group(osync_proxy_get_member(proxy)), memberstring, NULL); 855 852 execlp("./osplugin", "osplugin", "-f", readfd, writefd, NULL); 856 853 } 857 858 g_free(readfd); 859 g_free(writefd); 860 861 osync_trace(TRACE_INTERNAL, "unable to exec"); 854 855 osync_trace(TRACE_INTERNAL, strerror(errno)); 856 osync_trace(TRACE_INTERNAL, "Unable to execute osplugin."); 862 857 exit(1); 863 858 } else { … … 866 861 osync_queue_disconnect(read1, error); 867 862 } 868 863 869 864 proxy->child_pid = cpid; 870 871 /* 872 while (!proxy->outgoing || !osync_queue_exists(proxy->outgoing)) { 873 osync_trace(TRACE_INTERNAL, "Waiting for other side to create fifo"); 874 g_usleep(500000); 875 } 876 865 866 //while (!osync_queue_exists(proxy->outgoing)) { 867 // osync_trace(TRACE_INTERNAL, "Waiting for other side to create fifo"); 868 // g_usleep(500000); 869 //} 870 877 871 osync_trace(TRACE_INTERNAL, "Queue was created"); 878 879 */880 881 872 } 882 883 /* 884 if (proxy->child_pid) { 885 if (!_osync_client_create_pidfile(proxy, error)) 886 goto error; 887 } 888 */ 873 874 //if (proxy->child_pid) { 875 // if (!_osync_client_create_pidfile(proxy, error)) 876 // goto error; 877 //} 889 878 } 890 879 … … 957 946 goto error; 958 947 } 959 960 948 osync_message_unref(message); 961 949 … … 969 957 osync_client_unref(proxy->client); 970 958 } else if (proxy->type == OSYNC_START_TYPE_PROCESS) { 971 972 959 if (proxy->child_pid) { 973 960 int status; … … 982 969 osync_trace(TRACE_INTERNAL, "Child has returned non-zero exit status (%d)", WEXITSTATUS(status)); 983 970 984 #if 0 985 if (!osync_client_remove_pidfile(proxy, error)) 986 goto error; 987 #endif 971 //if (!osync_client_remove_pidfile(client, error)) 972 // goto error; 988 973 } 989 990 991 974 992 975 /* First lets see if the old plugin exists, and kill it if it does */ 993 #if 0 994 if (!_osync_client_kill_old_osplugin(proxy, error)) 995 goto error; 996 #endif 976 //if (!_osync_client_kill_old_osplugin(proxy, error)) 977 // goto error; 997 978 } 998 979 trunk/opensync/client/osplugin.c
r2509 r2526 118 118 119 119 osync_client_unref(client); 120 121 osync_queue_free(incoming); 122 osync_queue_free(outgoing); 120 121 //queues are already freed with the client 122 //osync_queue_free(incoming); 123 //osync_queue_free(outgoing); 123 124 124 125 osync_trace(TRACE_EXIT, "%s", __func__); trunk/opensync/group/opensync_member_internals.h
r2356 r2526 29 29 char *configdata; 30 30 31 OSyncGroup *group;31 //OSyncGroup *group; 32 32 33 33 char *name; trunk/opensync/ipc/opensync_message.c
r1197 r2526 246 246 /*@}*/ 247 247 248 char* osync_message_get_commandstr(OSyncMessage *message) 249 { 250 char* cmdstr = "UNKNOWN"; 251 252 switch(message->cmd) 253 { 254 case OSYNC_MESSAGE_NOOP: 255 cmdstr = "OSYNC_MESSAGE_NOOP"; break; 256 case OSYNC_MESSAGE_CONNECT: 257 cmdstr = "OSYNC_MESSAGE_CONNECT"; break; 258 case OSYNC_MESSAGE_DISCONNECT: 259 cmdstr = "OSYNC_MESSAGE_DISCONNECT"; break; 260 case OSYNC_MESSAGE_GET_CHANGES: 261 cmdstr = "OSYNC_MESSAGE_GET_CHANGES"; break; 262 case OSYNC_MESSAGE_READ_CHANGE: 263 cmdstr = "OSYNC_MESSAGE_READ_CHANGE"; break; 264 case OSYNC_MESSAGE_COMMIT_CHANGE: 265 cmdstr = "OSYNC_MESSAGE_COMMIT_CHANGE"; break; 266 case OSYNC_MESSAGE_COMMITTED_ALL: 267 cmdstr = "OSYNC_MESSAGE_COMMITTED_ALL"; break; 268 case OSYNC_MESSAGE_SYNC_DONE: 269 cmdstr = "OSYNC_MESSAGE_SYNC_DONE"; break; 270 case OSYNC_MESSAGE_CALL_PLUGIN: 271 cmdstr = "OSYNC_MESSAGE_CALL_PLUGIN"; break; 272 case OSYNC_MESSAGE_NEW_CHANGE: 273 cmdstr = "OSYNC_MESSAGE_NEW_CHANGE"; break; 274 case OSYNC_MESSAGE_REPLY: 275 cmdstr = "OSYNC_MESSAGE_REPLY"; break; 276 case OSYNC_MESSAGE_ERRORREPLY: 277 cmdstr = "OSYNC_MESSAGE_ERRORREPLY"; break; 278 case OSYNC_MESSAGE_INITIALIZE: 279 cmdstr = "OSYNC_MESSAGE_INITIALIZE"; break; 280 case OSYNC_MESSAGE_FINALIZE: 281 cmdstr = "OSYNC_MESSAGE_FINALIZE"; break; 282 case OSYNC_MESSAGE_DISCOVER: 283 cmdstr = "OSYNC_MESSAGE_DISCOVER"; break; 284 case OSYNC_MESSAGE_SYNCHRONIZE: 285 cmdstr = "OSYNC_MESSAGE_SYNCHRONIZE"; break; 286 case OSYNC_MESSAGE_ENGINE_CHANGED: 287 cmdstr = "OSYNC_MESSAGE_ENGINE_CHANGED"; break; 288 case OSYNC_MESSAGE_MAPPING_CHANGED: 289 cmdstr = "OSYNC_MESSAGE_MAPPING_CHANGED"; break; 290 case OSYNC_MESSAGE_MAPPINGENTRY_CHANGED: 291 cmdstr = "OSYNC_MESSAGE_MAPPINGENTRY_CHANGED"; break; 292 case OSYNC_MESSAGE_ERROR: 293 cmdstr = "OSYNC_MESSAGE_ERROR"; break; 294 case OSYNC_MESSAGE_QUEUE_ERROR: 295 cmdstr = "OSYNC_MESSAGE_QUEUE_ERROR"; break; 296 case OSYNC_MESSAGE_QUEUE_HUP: 297 cmdstr = "OSYNC_MESSAGE_QUEUE_HUP"; break; 298 } 299 300 return cmdstr; 301 } 302 248 303 void osync_message_write_int(OSyncMessage *message, int value) 249 304 { trunk/opensync/ipc/opensync_message.h
r1974 r2526 72 72 osync_bool osync_message_send_with_timeout(OSyncMessage *message, OSyncQueue *queue, OSyncQueue *replyQueue, int timeout, OSyncError **error); 73 73 OSyncMessageCommand osync_message_get_command(OSyncMessage *message); 74 char* osync_message_get_commandstr(OSyncMessage *message); 74 75 void osync_message_reset_timeout(OSyncMessage *message); 75 76 osync_bool osync_message_is_answered(OSyncMessage *message); trunk/opensync/ipc/opensync_queue.c
r2510 r2526 2 2 * libosengine - A synchronization engine for the opensync framework 3 3 * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> 4 * Copyright (C) 2007 Daniel Friedrich <daniel.friedrich@opensync.org> 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 67 68 while ((message = g_async_queue_try_pop(queue->incoming))) { 68 69 /* We check if the message is a reply to something */ 69 osync_trace(TRACE_INTERNAL, "Dispatching %p:%i ", message, osync_message_get_cmd(message));70 osync_trace(TRACE_INTERNAL, "Dispatching %p:%i(%s)", message, osync_message_get_cmd(message), osync_message_get_commandstr(message)); 70 71 71 72 if (osync_message_get_cmd(message) == OSYNC_MESSAGE_REPLY || osync_message_get_cmd(message) == OSYNC_MESSAGE_ERRORREPLY) { … … 651 652 } 652 653 queue->fd = fd; 653 int oldflags = fcntl(queue->fd, F_GETFD); 654 if (oldflags == -1) { 655 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get fifo flags"); 656 goto error_close; 657 } 658 if (fcntl(queue->fd, F_SETFD, oldflags|FD_CLOEXEC) == -1) { 659 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to set fifo flags"); 660 goto error_close; 661 } 654 } 655 656 int oldflags = fcntl(queue->fd, F_GETFD); 657 if (oldflags == -1) { 658 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get fifo flags"); 659 goto error_close; 660 } 661 if (fcntl(queue->fd, F_SETFD, oldflags|FD_CLOEXEC) == -1) { 662 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to set fifo flags"); 663 goto error_close; 662 664 } 663 665 trunk/opensync/plugin/opensync_plugin_internals.h
r2065 r2526 44 44 OSyncStartType start_type; 45 45 /** The pointer to the plugin (for internal use) */ 46 OSyncModule *module;46 //OSyncModule *module; 47 47 /** Plugin-specific data 48 48 *
