Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
f6db428a
Commit
f6db428a
authored
Feb 14, 2006
by
Arne Øslebø
Browse files
race condition bug fixes
git-svn-id:
file:///home/svn/mapi/trunk@350
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
10946eaa
Changes
5
Hide whitespace changes
Inline
Side-by-side
mapi.c
View file @
f6db428a
...
...
@@ -1399,9 +1399,13 @@ void* mapi_read_results(int fd, int fid)
return
(
0
);
else
{
// printf("Lock...\n");
pthread_spin_lock
(
flow
->
shm_spinlock
);
//printf("Locked\n");
memcpy
(
f
->
result
,((
shm_result_t
*
)
f
->
data
)
->
ptr
,((
shm_result_t
*
)
f
->
data
)
->
size
);
//printf("Unlock...\n");
pthread_spin_unlock
(
flow
->
shm_spinlock
);
//printf("Unlocked\n");
return
f
->
result
;
}
}
...
...
@@ -1727,8 +1731,9 @@ default_read_result_init(flowdescr_t *flow,functdescr_t* f,void* data)
id
=
shmget
(
shm_spinlock
->
key
,
shm_spinlock
->
buf_size
,
660
);
if
(
id
<
0
)
{
DEBUG_CMD
(
printf
(
"Shared memory error [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
mapi_set_error
(
flow
,
MAPI_SHM_ERR
);
DEBUG_CMD
(
printf
(
"Shared memory error:%m [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
perror
(
"Error: "
);
mapi_set_error
(
flow
,
MAPI_SHM_ERR
);
return
-
1
;
}
...
...
mapidagdrv.c
View file @
f6db428a
...
...
@@ -100,12 +100,12 @@ int mapidrv_delete_device(int devid)
}
}
if
((
err
=
pthread_join
(
i
->
th_proc
,
NULL
))
!=
0
)
{
/*
if ((err=pthread_join(i->th_proc,NULL))!=0) {
if (!(i->hwinfo.offline==1 && err==ESRCH)) {
WARNING_CMD(printf("Could not join thread for devid %d (%s) [%s:%d]\n",devid,strerror(err),__FILE__,__LINE__));
fflush(stdout);
}
}
}*/
}
if
(
i
->
hwinfo
.
offline
==
0
)
{
...
...
@@ -143,7 +143,7 @@ process_pkts(void *buf,unsigned len, dag_instance_t *i)
rec
=
(
dag_record_t
*
)
buf
;
rlen
=
ntohs
(
rec
->
rlen
);
mapid_lock
(
&
i
->
mapidlib
);
mapid_lock
(
&
i
->
mapidlib
);
while
(
c
+
rlen
<
len
)
{
char
*
p
=
buf
;
...
...
@@ -165,7 +165,7 @@ process_pkts(void *buf,unsigned len, dag_instance_t *i)
rlen
=
ntohs
(
rec
->
rlen
);
i
->
hwinfo
.
pkts
++
;
}
mapid_unlock
(
&
i
->
mapidlib
);
mapid_unlock
(
&
i
->
mapidlib
);
return
len
-
c
;
...
...
@@ -443,7 +443,7 @@ mapidrv_connect (int devid,int fd)
{
dag_instance_t
*
i
=
flist_get
(
devlist
,
devid
);
if
(
i
==
NULL
)
return
;
return
-
1
;
return
mapid_connect
(
&
i
->
mapidlib
,
fd
);
}
...
...
mapidlib.c
View file @
f6db428a
...
...
@@ -101,16 +101,21 @@ mapid_init(mapidlib_instance_t *i)
//Initialize spinlock
pthread_spin_init
(
i
->
shm_spinlock
,
PTHREAD_PROCESS_SHARED
);
i
->
shm_spinlock_size
=
sizeof
(
pthread_spinlock_t
);
return
0
;
};
void
mapid_lock
(
mapidlib_instance_t
*
i
)
{
// printf("Lock..\n");
pthread_spin_lock
(
i
->
shm_spinlock
);
//printf("Locked\n");
}
void
mapid_unlock
(
mapidlib_instance_t
*
i
)
{
//printf("Unlock..\n");
pthread_spin_unlock
(
i
->
shm_spinlock
);
//printf("Unlocked\n");
}
//Function that can be used by MAPI functions for adding new functions to the flow
...
...
mapinicdrv.c
View file @
f6db428a
...
...
@@ -479,7 +479,7 @@ mapidrv_close_flow (int devid,int fd)
{
nic_instance_t
*
i
=
flist_get
(
devlist
,
devid
);
if
(
i
==
NULL
)
return
;
return
-
1
;
return
mapid_close_flow
(
&
i
->
mapidlib
,
fd
);
}
...
...
stdlib/tobuffer_all.c
View file @
f6db428a
...
...
@@ -12,7 +12,7 @@
#include "mapid.h"
#include "fhelp.h"
#define NUM_PKTS
1
000 //Number of packets stored in buffer
#define NUM_PKTS
5
000 //Number of packets stored in buffer
typedef
struct
to_buffer
{
unsigned
long
read_ptr
;
//Pointer to the last packet that was read
...
...
@@ -113,9 +113,10 @@ static int toba_process(mapidflib_function_instance_t *instance,
//printf("WAIT\n");
if
(
semop
(
mbuf
->
sem
.
id
,
&
sem_wait
,
1
)
!=
0
)
fprintf
(
stderr
,
"error semop 2
\n
"
);
//Wait till it is 0 again
toba_process
(
instance
,
dev_pkt
,
pkt
,
pkt_head
);
}
else
{
DEBUG_CMD
(
printf
(
"TO_BUFFER : Packet dropped
\n
"
));
}
}
//else {
// DEBUG_CMD(printf("TO_BUFFER : Packet dropped\n"));
//}
}
else
{
(
*
(
unsigned
long
*
)(
mbuf
->
buf
+
mbuf
->
write_ptr
))
=
new_write
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment