Commit c7ecd427 authored by 's avatar
Browse files

fixed a bug in reconnection

git-svn-id: file:///home/svn/mapi/trunk@1193 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent a9a14214
......@@ -123,10 +123,10 @@ flist_t *offline_device_list = NULL; // list which contains all offline devices
int mapiipc_write(struct mapiipcbuf *qbuf){ // sends an IPC message to mapid
qbuf->uid = getuid(); // returns the real user ID of the current process
if(send(sock, qbuf, sizeof(struct mapiipcbuf), MSG_NOSIGNAL) == -1){
WARNING_CMD(printf("send: %s [%s:%d]\n", strerror(errno), __FILE__, __LINE__));
WARNING_CMD(printf("\nsend: %s [%s:%d]\n", strerror(errno), __FILE__, __LINE__));
#ifdef RECONNECT
offline_device *device = NULL;
......@@ -180,9 +180,8 @@ int mapiipc_write(struct mapiipcbuf *qbuf){ // sends an IPC message to mapid
qbuf->fd = flow->fd;
qbuf->fid = fun->fid;
}
send(sock, qbuf, sizeof(struct mapiipcbuf), MSG_NOSIGNAL);
#else
return -1;
#endif
......@@ -568,17 +567,19 @@ int mapiipc_remote_init(struct host *h)
return -1;
}
/*
tv.tv_sec=20; //timeout 20 sec for recv
tv.tv_usec=0;
if (setsockopt(h->sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval)) == -1) {
close(h->sockfd);
printf("Unexpected error on setsockopt()");
//exit(-1);
return -1;
/*#ifdef RECONNECT
tv.tv_sec = 40; // 40 seconds timeout
tv.tv_usec = 0;
// SO_RCVTIMEO is an option to set a timeout value for input operations
if(setsockopt(h->sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval)) == -1){
close(h->sockfd);
printf("Unexpected error on setsockopt() : %s", strerror(errno));
return -1;
}
*/
#endif
*/
tv.tv_sec=10; //timeout 10 sec for send
tv.tv_usec=0;
......@@ -1529,7 +1530,7 @@ void mapi_recreate_flow_mapid(void){
if(qbuf.cmd == CREATE_FLOW_ACK){
//printf("\n\t New fd = %d, Previous fd = %d", qbuf.fd, flow->fd);
//printf("\n\t New fd = %d, Previous fd = %d\n", qbuf.fd, flow->fd);
flow->fd = qbuf.fd; // the new fd of the flow
strcpy(flow->devtype, (char *) qbuf.data); // XXX
}
......@@ -1568,7 +1569,7 @@ void mapi_recreate_flow_mapid(void){
if(qbuf.cmd == CREATE_OFFLINE_FLOW_ACK){
//printf("\n\t New fd = %d, Previous fd = %d \t off-line", qbuf.fd, flow->fd);
//printf("\n\t New fd = %d, Previous fd = %d \t off-line\n", qbuf.fd, flow->fd);
flow->fd = qbuf.fd; // the new fd of the flow
strcpy(flow->devtype, (char *) qbuf.data); // XXX
flow->file = file; // new file descriptor of offline flow
......@@ -1579,6 +1580,7 @@ void mapi_recreate_flow_mapid(void){
}
}
}
return;
}
......@@ -1755,7 +1757,7 @@ void mapi_reapply_function_mapid(void){
fun->fid = qbuf.fid; // change previous fid with the new one
fun->funct->fid = qbuf.fid;
memcpy(fun->funct->instance->args, qbuf.data, FUNCTARGS_BUF_SIZE); // copy arguments
//memcpy(fun->funct->instance->args, qbuf.data, FUNCTARGS_BUF_SIZE); // copy arguments
}
else{
fprintf(stderr, "\nError: Could not re-apply function %s [%s : %d]\n", fun->def->name, __FILE__, __LINE__);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment