acceptfd = accept(listenfd, (struct sockaddr *)&client_addr, &addrlength);
pthread_create(&thread_dstm_accept, NULL, dstmAccept, (void *)acceptfd);
}
- pthread_exit(NULL);
}
/* This function accepts a new connection request, decodes the control message in the connection
* and accordingly calls other functions to process new requests */
trans_commit_data_t transinfo;
unsigned short objType;
+ transinfo.objlocked = NULL;
+ transinfo.objnotfound = NULL;
+ transinfo.modptr = NULL;
+ transinfo.numlocked = 0;
+ transinfo.numnotfound = 0;
+
int fd_flags = fcntl((int)acceptfd, F_GETFD), size;
/* Receive control messages from other machines */
if((retval = recv((int)acceptfd, &control, sizeof(char), 0)) <= 0) {
if (retval == 0) {
- return; // Testing connection
+ pthread_exit(NULL); // Testing connection
}
perror("Error in receiving control from coordinator\n");
- return;
+ pthread_exit(NULL);
}
switch(control) {
/* Read oid requested and search if available */
if((retval = recv((int)acceptfd, &oid, sizeof(unsigned int), 0)) <= 0) {
perror("Error receiving object from cooridnator\n");
- return NULL;
+ pthread_exit(NULL);
}
if((srcObj = mhashSearch(oid)) == NULL) {
printf("Object not found in Main Object Store %s %d\n", __FILE__, __LINE__);
ctrl = OBJECT_NOT_FOUND;
if(send((int)acceptfd, &ctrl, sizeof(char), MSG_NOSIGNAL) < sizeof(char)) {
perror("Error sending control msg to coordinator\n");
- return NULL;
+ pthread_exit(NULL);
}
} else {
/* Type */
*((int *)&msg[1])=size;
if(send((int)acceptfd, &msg, sizeof(msg), MSG_NOSIGNAL) < sizeof(msg)) {
perror("Error sending size of object to coordinator\n");
- return NULL;
+ pthread_exit(NULL);
}
if(send((int)acceptfd, h, size, MSG_NOSIGNAL) < size) {
perror("Error in sending object\n");
- return NULL;
+ pthread_exit(NULL);
}
}
break;
printf("DEBUG -> Recv TRANS_REQUEST\n");
if((val = readClientReq(&transinfo, (int)acceptfd)) != 0) {
printf("Error in readClientReq\n");
- return;
+ pthread_exit(NULL);
}
break;
case TRANS_PREFETCH:
printf("DEBUG -> Recv TRANS_PREFETCH\n");
if((val = prefetchReq((int)acceptfd)) != 0) {
printf("Error in readClientReq\n");
- return;
+ pthread_exit(NULL);
}
break;
case START_REMOTE_THREAD:
objheader_t *headaddr;
int sum = 0, i, N, n, val;
+ oidmod = NULL;
+
/* Read fixed_data_t data structure */
N = sizeof(fixed) - 1;
ptr = (char *)&fixed;;
/* Create an array of oids for modified objects */
oidmod = (unsigned int *) calloc(fixed.nummod, sizeof(unsigned int));
+ if (oidmod == NULL)
+ {
+ printf("calloc error %s, %d\n", __FILE__, __LINE__);
+ return 1;
+ }
ptr = (char *) modptr;
for(i = 0 ; i < fixed.nummod; i++) {
int tmpsize;
short version;
char control = 0, *ptr;
unsigned int oid;
- unsigned int *oidnotfound, *oidlocked, *oidmod;
+ unsigned int *oidnotfound, *oidlocked;
void *mobj;
objheader_t *headptr;
if ((mobj = mhashSearch(oid)) == NULL) {/* Obj not found */
/* Save the oids not found and number of oids not found for later use */
- //oidnotfound[objnotfound] = OID(((objheader_t *)mobj));
oidnotfound[objnotfound] = oid;
objnotfound++;
} else { /* If Obj found in machine (i.e. has not moved) */