diff -Naur lwip_patch_warnings/src/core/pbuf.c lwip_patch_pbufalloc/src/core/pbuf.c
--- lwip_patch_warnings/src/core/pbuf.c	2006-10-10 09:52:28.887659000 +0200
+++ lwip_patch_pbufalloc/src/core/pbuf.c	2006-10-11 09:51:38.755915000 +0200
@@ -76,8 +76,7 @@
 static u8_t pbuf_pool_memory[MEM_ALIGNMENT - 1 + PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE + sizeof(struct pbuf))];
 
 #if !SYS_LIGHTWEIGHT_PROT
-static volatile u8_t pbuf_pool_free_lock, pbuf_pool_alloc_lock;
-static sys_sem_t pbuf_pool_free_sem;
+static sys_sem_t pbuf_pool_sem;
 #endif
 
 static struct pbuf *pbuf_pool = NULL;
@@ -123,9 +122,7 @@
   q->next = NULL;
 
 #if !SYS_LIGHTWEIGHT_PROT
-  pbuf_pool_alloc_lock = 0;
-  pbuf_pool_free_lock = 0;
-  pbuf_pool_free_sem = sys_sem_new(1);
+  pbuf_pool_sem = sys_sem_new(1);
 #endif
 }
 
@@ -137,33 +134,23 @@
 {
   struct pbuf *p = NULL;
 
+#if SYS_LIGHTWEIGHT_PROT
   SYS_ARCH_DECL_PROTECT(old_level);
   SYS_ARCH_PROTECT(old_level);
+#else
+    sys_sem_wait(pbuf_pool_sem);
+#endif /* SYS_LIGHTWEIGHT_PROT */  
 
-#if !SYS_LIGHTWEIGHT_PROT
-  /* Next, check the actual pbuf pool, but if the pool is locked, we
-     pretend to be out of buffers and return NULL. */
-  if (pbuf_pool_free_lock) {
-#if PBUF_STATS
-    ++lwip_stats.pbuf.alloc_locked;
-#endif /* PBUF_STATS */
-    return NULL;
-  }
-  pbuf_pool_alloc_lock = 1;
-  if (!pbuf_pool_free_lock) {
-#endif /* SYS_LIGHTWEIGHT_PROT */
     p = pbuf_pool;
     if (p) {
       pbuf_pool = p->next;
     }
-#if !SYS_LIGHTWEIGHT_PROT
-#if PBUF_STATS
-  } else {
-    ++lwip_stats.pbuf.alloc_locked;
-#endif /* PBUF_STATS */
-  }
-  pbuf_pool_alloc_lock = 0;
-#endif /* SYS_LIGHTWEIGHT_PROT */
+
+#if SYS_LIGHTWEIGHT_PROT
+  SYS_ARCH_UNPROTECT(old_level);
+#else
+    sys_sem_signal(pbuf_pool_sem);
+#endif /* SYS_LIGHTWEIGHT_PROT */  
 
 #if PBUF_STATS
   if (p != NULL) {
@@ -174,7 +161,6 @@
   }
 #endif /* PBUF_STATS */
 
-  SYS_ARCH_UNPROTECT(old_level);
   return p;
 }
 
@@ -364,9 +350,9 @@
                                } while (0)
 #else /* SYS_LIGHTWEIGHT_PROT */
 #define PBUF_POOL_FREE(p)  do {                                         \
-                             sys_sem_wait(pbuf_pool_free_sem);          \
+                             sys_sem_wait(pbuf_pool_sem);          \
                              PBUF_POOL_FAST_FREE(p);                    \
-                             sys_sem_signal(pbuf_pool_free_sem);        \
+                             sys_sem_signal(pbuf_pool_sem);        \
                            } while (0)
 #endif /* SYS_LIGHTWEIGHT_PROT */
 
@@ -549,7 +535,10 @@
   u16_t flags;
   struct pbuf *q;
   u8_t count;
+
+#if SYS_LIGHTWEIGHT_PROT
   SYS_ARCH_DECL_PROTECT(old_level);
+#endif /* SYS_LIGHTWEIGHT_PROT */
 
   LWIP_ASSERT("p != NULL", p != NULL);
   /* if assertions are disabled, proceed with debug output */
@@ -569,7 +558,11 @@
   /* Since decrementing ref cannot be guaranteed to be a single machine operation
    * we must protect it. Also, the later test of ref must be protected.
    */
+#if SYS_LIGHTWEIGHT_PROT
   SYS_ARCH_PROTECT(old_level);
+#else
+  sys_sem_wait(pbuf_pool_sem);
+#endif /* SYS_LIGHTWEIGHT_PROT */
   /* de-allocate all consecutive pbufs from the head of the chain that
    * obtain a zero reference count after decrementing*/
   while (p != NULL) {
@@ -587,7 +580,7 @@
       if (flags == PBUF_FLAG_POOL) {
         p->len = p->tot_len = PBUF_POOL_BUFSIZE;
         p->payload = (void *)((u8_t *)p + sizeof(struct pbuf));
-        PBUF_POOL_FREE(p);
+        PBUF_POOL_FAST_FREE(p);
       /* is this a ROM or RAM referencing pbuf? */
       } else if (flags == PBUF_FLAG_ROM || flags == PBUF_FLAG_REF) {
         memp_free(MEMP_PBUF, p);
@@ -606,7 +599,11 @@
       p = NULL;
     }
   }
+#if SYS_LIGHTWEIGHT_PROT
   SYS_ARCH_UNPROTECT(old_level);
+#else
+  sys_sem_signal(pbuf_pool_sem);
+#endif /* SYS_LIGHWEIGHT_PROT */
   PERF_STOP("pbuf_free");
   /* return number of de-allocated pbufs */
   return count;
@@ -641,12 +638,22 @@
 void
 pbuf_ref(struct pbuf *p)
 {
+#if SYS_LIGHTWEIGHT_PROT
   SYS_ARCH_DECL_PROTECT(old_level);
+#endif /* SYS_LIGHTWEIGHT_PROT */
   /* pbuf given? */
   if (p != NULL) {
+#if SYS_LIGHTWEIGHT_PROT
     SYS_ARCH_PROTECT(old_level);
+#else
+    sys_sem_wait(pbuf_pool_sem);
+#endif /* SYS_LIGHTWEIGHT_PROT */
     ++(p->ref);
+#if SYS_LIGHTWEIGHT_PROT
     SYS_ARCH_UNPROTECT(old_level);
+#else
+    sys_sem_signal(pbuf_pool_sem);
+#endif /* SYS_LIGHTWEIGHT_PROT */
   }
 }
 
