Changeset 2511
- Timestamp:
- 09/02/07 18:11:41 (1 year ago)
- Files:
-
- trunk/opensync/client/opensync_client_proxy.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/opensync/client/opensync_client_proxy.c
r2488 r2511 35 35 36 36 #include <sys/types.h> 37 #include <sys/wait.h> 37 38 #include <signal.h> 38 39 … … 78 79 79 80 //portable kill pid helper 81 #if 0 80 82 static int _osync_kill(pid_t pid, int sig) 81 83 { … … 106 108 #endif //_WIN32 107 109 } 108 110 #endif 111 112 #if 0 109 113 static char *_osync_client_pid_filename(OSyncClientProxy *proxy) 110 114 { … … 112 116 } 113 117 114 /*static osync_bool osync_client_remove_pidfile(OSyncClientProxy *proxy, OSyncError **error)118 static osync_bool osync_client_remove_pidfile(OSyncClientProxy *proxy, OSyncError **error) 115 119 { 116 120 char *pidpath = _osync_client_pid_filename(proxy); … … 140 144 g_free(pidpath); 141 145 return TRUE; 142 } */146 } 143 147 144 148 static osync_bool _osync_client_kill_old_osplugin(OSyncClientProxy *proxy, OSyncError **error) … … 199 203 return ret; 200 204 } 205 #endif 201 206 202 207 /** This function takes care of the messages received on the outgoing (sending) … … 800 805 goto error_free_pipe1; 801 806 807 proxy->outgoing = write1; 808 proxy->incoming = read2; 809 802 810 /* Now we either spawn a new process, or we create a new thread */ 803 811 if (type == OSYNC_START_TYPE_THREAD) { … … 822 830 } else { 823 831 /* First lets see if the old plugin exists, and kill it if it does */ 832 #if 0 824 833 if (!_osync_client_kill_old_osplugin(proxy, error)) 825 834 goto error; 826 827 /*todo*/ 828 829 830 831 /*if (!osync_queue_exists(proxy->outgoing) || !osync_queue_is_alive(proxy->outgoing)) { 832 pid_t cpid = fork(); 833 if (cpid == 0) { 834 osync_trace_reset_indent(); 835 836 osync_trace(TRACE_INTERNAL, "About to exec osplugin"); 837 char *memberstring = g_strdup_printf("%lli", osync_member_get_id(proxy->member)); 838 execlp("osplugin", "osplugin", osync_group_get_configdir(engine->group), memberstring, NULL); 835 #endif 836 837 if (!proxy->outgoing || !osync_queue_exists(proxy->outgoing) || !osync_queue_is_alive(proxy->outgoing)) { 838 pid_t cpid = fork(); 839 if (cpid == 0) { 840 osync_trace_reset_indent(); 841 842 char *readfd = g_strdup_printf("%i", osync_queue_get_fd(read1)); 843 char *writefd = g_strdup_printf("%i", osync_queue_get_fd(write2)); 844 845 osync_trace(TRACE_INTERNAL, "About to exec osplugin"); 846 execlp("osplugin", "osplugin", "-f", readfd, writefd, NULL); 847 848 if (errno == ENOENT) { 849 osync_trace(TRACE_INTERNAL, "Unable to find osplugin. Trying local path."); 850 execlp("./osplugin", "osplugin", "-f", readfd, writefd, NULL); 851 } 852 853 g_free(readfd); 854 g_free(writefd); 855 856 osync_trace(TRACE_INTERNAL, "unable to exec"); 857 exit(1); 858 } 859 860 proxy->child_pid = cpid; 839 861 840 if (errno == ENOENT) { 841 osync_trace(TRACE_INTERNAL, "Unable to find osplugin. Trying local path."); 842 execlp("./osplugin", "osplugin", osync_group_get_configdir(engine->group), memberstring, NULL); 862 /* 863 while (!proxy->outgoing || !osync_queue_exists(proxy->outgoing)) { 864 osync_trace(TRACE_INTERNAL, "Waiting for other side to create fifo"); 865 g_usleep(500000); 843 866 } 844 867 845 osync_trace(TRACE_INTERNAL, "unable to exec"); 846 exit(1); 868 osync_trace(TRACE_INTERNAL, "Queue was created"); 869 870 */ 871 847 872 } 848 849 proxy->child_pid = cpid; 850 851 while (!osync_queue_exists(proxy->outgoing)) { 852 osync_trace(TRACE_INTERNAL, "Waiting for other side to create fifo"); 853 g_usleep(500000); 873 874 /* 875 if (proxy->child_pid) { 876 if (!_osync_client_create_pidfile(proxy, error)) 877 goto error; 854 878 } 855 856 osync_trace(TRACE_INTERNAL, "Queue was created"); 879 */ 857 880 } 858 859 if (proxy->child_pid) { 860 if (!_osync_client_create_pidfile(proxy, error)) 861 goto error; 862 }*/ 863 } 864 865 proxy->outgoing = write1; 866 proxy->incoming = read2; 867 881 868 882 /* We now connect to our incoming queue */ 869 883 if (!osync_queue_connect(proxy->incoming, OSYNC_QUEUE_RECEIVER, error)) … … 946 960 osync_client_unref(proxy->client); 947 961 } else if (proxy->type == OSYNC_START_TYPE_PROCESS) { 948 /*if (client->child_pid) { 949 int status; 950 if (waitpid(client->child_pid, &status, 0) == -1) { 951 osync_error_set(error, OSYNC_ERROR_GENERIC, "Error waiting for osplugin process: %s", g_strerror(errno)); 952 goto error; 962 963 if (proxy->child_pid) { 964 int status; 965 if (waitpid(proxy->child_pid, &status, 0) == -1) { 966 osync_error_set(error, OSYNC_ERROR_GENERIC, "Error waiting for osplugin process: %s", g_strerror(errno)); 967 goto error; 968 } 969 970 if (!WIFEXITED(status)) 971 osync_trace(TRACE_INTERNAL, "Child has exited abnormally"); 972 else if (WEXITSTATUS(status) != 0) 973 osync_trace(TRACE_INTERNAL, "Child has returned non-zero exit status (%d)", WEXITSTATUS(status)); 974 975 #if 0 976 if (!osync_client_remove_pidfile(proxy, error)) 977 goto error; 978 #endif 953 979 } 954 980 955 if (!WIFEXITED(status))956 osync_trace(TRACE_INTERNAL, "Child has exited abnormally");957 else if (WEXITSTATUS(status) != 0)958 osync_trace(TRACE_INTERNAL, "Child has returned non-zero exit status (%d)", WEXITSTATUS(status));959 960 if (!osync_client_remove_pidfile(client, error))961 goto error;962 }*/963 981 964 982 965 983 /* First lets see if the old plugin exists, and kill it if it does */ 984 #if 0 966 985 if (!_osync_client_kill_old_osplugin(proxy, error)) 967 986 goto error; 987 #endif 968 988 } 969 989
