Commit 200556e4 authored by 's avatar
Browse files

Fixed a possible deadlock bug in VOd.


git-svn-id: file:///home/svn/mapi/trunk@569 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 9916bca5
......@@ -7,15 +7,15 @@ CFEATURES=-D_GNU_SOURCE -D_THREAD_SAFE
CDEBUG=-g
CFLAGS=$(CDEBUG) $(CWARNINGS) $(CFEATURES) $(COPTIMIZATIONS)
TARGETS=btheap vod flist.o
TARGETS=btheap vod
all: $(TARGETS)
vod: vod.c vod.h flist.o BTHeap/btheap.o ../parseconf.h ../parseconf.o ../anonymization/names.h ../anonymization/names.c
vod: vod.c vod.h ../flist.h ../flist.o BTHeap/btheap.o ../parseconf.h ../parseconf.o ../anonymization/names.h ../anonymization/names.c
$(CC) $(CFLAGS) -o $@ $^ -lcrypto -lssl -lpthread
flist.o: flist.c flist.h
$(CC) $(CFLAGS) -c $<
#flist.o: flist.c flist.h
# $(CC) $(CFLAGS) -c $<
btheap: BTHeap/btheap.c BTHeap/btheap.h
cd BTHeap && make btheap.o
......
......@@ -384,16 +384,16 @@ int build_policies()
conf_parameter_t *function = NULL;
char *ptr = NULL;
pthread_mutex_lock(&list_lock);
if(!vos)
return(0);
return(-1);
else
node = vos->head;
if(pc_load(policyfile) != 1)
return(-1);
pthread_mutex_lock(&list_lock);
while(node)
{
vo = (vo_info_t *) node->data;
......@@ -406,7 +406,13 @@ int build_policies()
}
else
{
vo->policy = malloc(sizeof(flist_t));
fprintf(stderr, " * Loading policy for VO %s...\n", vo->vo_name);
if((vo->policy = malloc(sizeof(flist_t))) == NULL)
{
pc_close();
pthread_mutex_unlock(&list_lock);
return(-1);
}
flist_init(vo->policy);
function = entry->params;
......@@ -602,7 +608,8 @@ int send_nic_list(int mapid_socket, auth_msg_t *data)
if(vos)
temp = vos->head;
pthread_mutex_lock(&list_lock);
while(temp)
{
vo = temp->data;
......@@ -613,7 +620,8 @@ int send_nic_list(int mapid_socket, auth_msg_t *data)
break;
}
}
pthread_mutex_unlock(&list_lock);
if(!found)
{
struct stat stat_buf;
......@@ -631,7 +639,12 @@ int send_nic_list(int mapid_socket, auth_msg_t *data)
goto failure;
}
temp = vos->head;
if(vos)
temp = vos->head;
else
goto failure;
pthread_mutex_lock(&list_lock);
while(temp)
{
vo = temp->data;
......@@ -642,6 +655,7 @@ int send_nic_list(int mapid_socket, auth_msg_t *data)
break;
}
}
pthread_mutex_unlock(&list_lock);
if(!found) { goto failure; }
}
else
......@@ -719,6 +733,7 @@ int send_policy(int mapid_socket, auth_msg_t *request)
return(0);
}
pthread_mutex_lock(&list_lock);
while(tmp_node)
{
vo = tmp_node->data;
......@@ -732,9 +747,11 @@ int send_policy(int mapid_socket, auth_msg_t *request)
response.opcode = POLICY_NOTFOUND;
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
pthread_mutex_unlock(&list_lock);
perror("send");
return(-1);
}
pthread_mutex_unlock(&list_lock);
return(0);
}
......@@ -748,9 +765,11 @@ int send_policy(int mapid_socket, auth_msg_t *request)
response.opcode = POLICY_NOTFOUND;
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
perror("send");
return(-1);
pthread_mutex_unlock(&list_lock);
perror("send");
return(-1);
}
pthread_mutex_unlock(&list_lock);
return(0);
}
else
......@@ -773,15 +792,18 @@ int send_policy(int mapid_socket, auth_msg_t *request)
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
pthread_mutex_unlock(&list_lock);
perror("send");
return(-1);
}
if(send(mapid_socket, policy, len, 0) == -1)
{
pthread_mutex_unlock(&list_lock);
perror("send");
return(-1);
}
pthread_mutex_unlock(&list_lock);
return(0);
}
else
......@@ -791,9 +813,12 @@ int send_policy(int mapid_socket, auth_msg_t *request)
response.opcode = POLICY_NOTFOUND;
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
pthread_mutex_unlock(&list_lock);
perror("send");
return(-1);
}
pthread_mutex_unlock(&list_lock);
return(0);
}
......
Markdown is supported
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