summaryrefslogtreecommitdiffstats
path: root/mbuf.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2010-11-18 22:17:58 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-11-18 22:17:58 +0100
commit529df9922d85574828d95020eebcd228ba3a8164 (patch)
tree8524b46dd4bbbd163d4ce273ea6e82edd7c4b947 /mbuf.c
parenteb208d36d466a1725e20e0a7aef39b1114b99e78 (diff)
parent7c18c6353904f8c6e7f4eab3d13c985761ab80e5 (diff)
downloadopenvpn-529df9922d85574828d95020eebcd228ba3a8164.tar.gz
openvpn-529df9922d85574828d95020eebcd228ba3a8164.tar.xz
openvpn-529df9922d85574828d95020eebcd228ba3a8164.zip
Merge branch 'feat_misc' into beta2.2
Conflicts: acinclude.m4 config-win32.h configure.ac misc.c thread.c thread.h - These conflicts was mainly due to feat_misc getting old and mostly caused by the pthread clean-up patches in feat_misc Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'mbuf.c')
-rw-r--r--mbuf.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/mbuf.c b/mbuf.c
index 7e21252..0f36d3c 100644
--- a/mbuf.c
+++ b/mbuf.c
@@ -38,7 +38,6 @@ mbuf_init (unsigned int size)
{
struct mbuf_set *ret;
ALLOC_OBJ_CLEAR (ret, struct mbuf_set);
- mutex_init (&ret->mutex);
ret->capacity = adjust_power_of_2 (size);
ALLOC_ARRAY (ret->array, struct mbuf_item, ret->capacity);
return ret;
@@ -56,7 +55,6 @@ mbuf_free (struct mbuf_set *ms)
mbuf_free_buf (item->buffer);
}
free (ms->array);
- mutex_destroy (&ms->mutex);
free (ms);
}
}
@@ -89,11 +87,10 @@ void
mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item)
{
ASSERT (ms);
- mutex_lock (&ms->mutex);
if (ms->len == ms->capacity)
{
struct mbuf_item rm;
- ASSERT (mbuf_extract_item (ms, &rm, false));
+ ASSERT (mbuf_extract_item (ms, &rm));
mbuf_free_buf (rm.buffer);
msg (D_MULTI_DROPPED, "MBUF: mbuf packet dropped");
}
@@ -104,17 +101,14 @@ mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item)
if (++ms->len > ms->max_queued)
ms->max_queued = ms->len;
++item->buffer->refcount;
- mutex_unlock (&ms->mutex);
}
bool
-mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item, const bool lock)
+mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item)
{
bool ret = false;
if (ms)
{
- if (lock)
- mutex_lock (&ms->mutex);
while (ms->len)
{
*item = ms->array[ms->head];
@@ -126,8 +120,6 @@ mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item, const bool lock)
break;
}
}
- if (lock)
- mutex_unlock (&ms->mutex);
}
return ret;
}
@@ -139,7 +131,6 @@ mbuf_peek_dowork (struct mbuf_set *ms)
if (ms)
{
int i;
- mutex_lock (&ms->mutex);
for (i = 0; i < (int) ms->len; ++i)
{
struct mbuf_item *item = &ms->array[MBUF_INDEX(ms->head, i, ms->capacity)];
@@ -149,7 +140,6 @@ mbuf_peek_dowork (struct mbuf_set *ms)
break;
}
}
- mutex_unlock (&ms->mutex);
}
return ret;
}
@@ -160,7 +150,6 @@ mbuf_dereference_instance (struct mbuf_set *ms, struct multi_instance *mi)
if (ms)
{
int i;
- mutex_lock (&ms->mutex);
for (i = 0; i < (int) ms->len; ++i)
{
struct mbuf_item *item = &ms->array[MBUF_INDEX(ms->head, i, ms->capacity)];
@@ -172,7 +161,6 @@ mbuf_dereference_instance (struct mbuf_set *ms, struct multi_instance *mi)
msg (D_MBUF, "MBUF: dereferenced queued packet");
}
}
- mutex_unlock (&ms->mutex);
}
}