Index: c/src/exec/libnetworking/rtems/rtems_glue.c
===================================================================
--- c/src/exec/libnetworking/rtems/rtems_glue.c	(revision 18cb17fd8c09fec7030549a8b01fb8e39edb6a01)
+++ c/src/exec/libnetworking/rtems/rtems_glue.c	(revision f74abcf78d0a57e8be59b350699c3091502c0913)
@@ -91,25 +91,17 @@
 {
 	void *p;
+	int try = 0;
 
 	for (;;) {
 		p = malloc (size);
-		if (p)
+		if (p || (flags & M_NOWAIT))
 			return p;
-		if (flags & M_NOWAIT)
-			return p;
-		/*
-		 * FIXME: This should be redone as:
-		 * static volatile int rtems_bsdnet_need_memory;
-		 *     
-		 *	rtems_bsdnet_need_memory = 1;
-		 *	message_queue_receive
-		 *
-		 * Then in rtems_bsdnet_freee:
-		 *	free (....);
-		 *	if (rtems_bsdnet_need_memory)
-		 *		rtems_bsdnet_need_memory = 0;
-		 *		message_queue_broadcast
-		 */
+		rtems_bsdnet_semaphore_release ();
+		if (++try >= 30) {
+			printf ("rtems_bsdnet_malloc still waiting.\n");
+			try = 0;
+		}
 		rtems_task_wake_after (rtems_bsdnet_ticks_per_second);
+		rtems_bsdnet_semaphore_obtain ();
 	}
 }
@@ -159,5 +151,5 @@
 
 	p = malloc(nmbuf * MSIZE + MSIZE - 1);
-	p = (char *)(((unsigned long)p + MSIZE - 1) & ~(MSIZE - 1));
+	p = (char *)(((unsigned int)p + MSIZE - 1) & ~(MSIZE - 1));
 	if (p == NULL)
 		rtems_panic ("Can't get network memory.");
@@ -657,5 +649,5 @@
 /*
  * Ticks till specified time
- * FIXME: This version worries only about seconds, but that's good
+ * XXX: This version worries only about seconds, but that's good
  * enough for the way the network code uses this routine.
  */
@@ -939,10 +931,19 @@
 	m_reclaim ();
 	if (mmbfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mmbfree == NULL);
+			if (mmbfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
@@ -959,10 +960,19 @@
 	m_reclaim ();
 	if (mclfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mclfree == NULL);
+			if (mclfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf cluster.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
Index: c/src/lib/libnetworking/rtems/rtems_glue.c
===================================================================
--- c/src/lib/libnetworking/rtems/rtems_glue.c	(revision 18cb17fd8c09fec7030549a8b01fb8e39edb6a01)
+++ c/src/lib/libnetworking/rtems/rtems_glue.c	(revision f74abcf78d0a57e8be59b350699c3091502c0913)
@@ -91,25 +91,17 @@
 {
 	void *p;
+	int try = 0;
 
 	for (;;) {
 		p = malloc (size);
-		if (p)
+		if (p || (flags & M_NOWAIT))
 			return p;
-		if (flags & M_NOWAIT)
-			return p;
-		/*
-		 * FIXME: This should be redone as:
-		 * static volatile int rtems_bsdnet_need_memory;
-		 *     
-		 *	rtems_bsdnet_need_memory = 1;
-		 *	message_queue_receive
-		 *
-		 * Then in rtems_bsdnet_freee:
-		 *	free (....);
-		 *	if (rtems_bsdnet_need_memory)
-		 *		rtems_bsdnet_need_memory = 0;
-		 *		message_queue_broadcast
-		 */
+		rtems_bsdnet_semaphore_release ();
+		if (++try >= 30) {
+			printf ("rtems_bsdnet_malloc still waiting.\n");
+			try = 0;
+		}
 		rtems_task_wake_after (rtems_bsdnet_ticks_per_second);
+		rtems_bsdnet_semaphore_obtain ();
 	}
 }
@@ -159,5 +151,5 @@
 
 	p = malloc(nmbuf * MSIZE + MSIZE - 1);
-	p = (char *)(((unsigned long)p + MSIZE - 1) & ~(MSIZE - 1));
+	p = (char *)(((unsigned int)p + MSIZE - 1) & ~(MSIZE - 1));
 	if (p == NULL)
 		rtems_panic ("Can't get network memory.");
@@ -657,5 +649,5 @@
 /*
  * Ticks till specified time
- * FIXME: This version worries only about seconds, but that's good
+ * XXX: This version worries only about seconds, but that's good
  * enough for the way the network code uses this routine.
  */
@@ -939,10 +931,19 @@
 	m_reclaim ();
 	if (mmbfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mmbfree == NULL);
+			if (mmbfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
@@ -959,10 +960,19 @@
 	m_reclaim ();
 	if (mclfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mclfree == NULL);
+			if (mclfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf cluster.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
Index: c/src/libnetworking/rtems/rtems_glue.c
===================================================================
--- c/src/libnetworking/rtems/rtems_glue.c	(revision 18cb17fd8c09fec7030549a8b01fb8e39edb6a01)
+++ c/src/libnetworking/rtems/rtems_glue.c	(revision f74abcf78d0a57e8be59b350699c3091502c0913)
@@ -91,25 +91,17 @@
 {
 	void *p;
+	int try = 0;
 
 	for (;;) {
 		p = malloc (size);
-		if (p)
+		if (p || (flags & M_NOWAIT))
 			return p;
-		if (flags & M_NOWAIT)
-			return p;
-		/*
-		 * FIXME: This should be redone as:
-		 * static volatile int rtems_bsdnet_need_memory;
-		 *     
-		 *	rtems_bsdnet_need_memory = 1;
-		 *	message_queue_receive
-		 *
-		 * Then in rtems_bsdnet_freee:
-		 *	free (....);
-		 *	if (rtems_bsdnet_need_memory)
-		 *		rtems_bsdnet_need_memory = 0;
-		 *		message_queue_broadcast
-		 */
+		rtems_bsdnet_semaphore_release ();
+		if (++try >= 30) {
+			printf ("rtems_bsdnet_malloc still waiting.\n");
+			try = 0;
+		}
 		rtems_task_wake_after (rtems_bsdnet_ticks_per_second);
+		rtems_bsdnet_semaphore_obtain ();
 	}
 }
@@ -159,5 +151,5 @@
 
 	p = malloc(nmbuf * MSIZE + MSIZE - 1);
-	p = (char *)(((unsigned long)p + MSIZE - 1) & ~(MSIZE - 1));
+	p = (char *)(((unsigned int)p + MSIZE - 1) & ~(MSIZE - 1));
 	if (p == NULL)
 		rtems_panic ("Can't get network memory.");
@@ -657,5 +649,5 @@
 /*
  * Ticks till specified time
- * FIXME: This version worries only about seconds, but that's good
+ * XXX: This version worries only about seconds, but that's good
  * enough for the way the network code uses this routine.
  */
@@ -939,10 +931,19 @@
 	m_reclaim ();
 	if (mmbfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mmbfree == NULL);
+			if (mmbfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
@@ -959,10 +960,19 @@
 	m_reclaim ();
 	if (mclfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mclfree == NULL);
+			if (mclfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf cluster.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
Index: cpukit/libnetworking/rtems/rtems_glue.c
===================================================================
--- cpukit/libnetworking/rtems/rtems_glue.c	(revision 18cb17fd8c09fec7030549a8b01fb8e39edb6a01)
+++ cpukit/libnetworking/rtems/rtems_glue.c	(revision f74abcf78d0a57e8be59b350699c3091502c0913)
@@ -91,25 +91,17 @@
 {
 	void *p;
+	int try = 0;
 
 	for (;;) {
 		p = malloc (size);
-		if (p)
+		if (p || (flags & M_NOWAIT))
 			return p;
-		if (flags & M_NOWAIT)
-			return p;
-		/*
-		 * FIXME: This should be redone as:
-		 * static volatile int rtems_bsdnet_need_memory;
-		 *     
-		 *	rtems_bsdnet_need_memory = 1;
-		 *	message_queue_receive
-		 *
-		 * Then in rtems_bsdnet_freee:
-		 *	free (....);
-		 *	if (rtems_bsdnet_need_memory)
-		 *		rtems_bsdnet_need_memory = 0;
-		 *		message_queue_broadcast
-		 */
+		rtems_bsdnet_semaphore_release ();
+		if (++try >= 30) {
+			printf ("rtems_bsdnet_malloc still waiting.\n");
+			try = 0;
+		}
 		rtems_task_wake_after (rtems_bsdnet_ticks_per_second);
+		rtems_bsdnet_semaphore_obtain ();
 	}
 }
@@ -159,5 +151,5 @@
 
 	p = malloc(nmbuf * MSIZE + MSIZE - 1);
-	p = (char *)(((unsigned long)p + MSIZE - 1) & ~(MSIZE - 1));
+	p = (char *)(((unsigned int)p + MSIZE - 1) & ~(MSIZE - 1));
 	if (p == NULL)
 		rtems_panic ("Can't get network memory.");
@@ -657,5 +649,5 @@
 /*
  * Ticks till specified time
- * FIXME: This version worries only about seconds, but that's good
+ * XXX: This version worries only about seconds, but that's good
  * enough for the way the network code uses this routine.
  */
@@ -939,10 +931,19 @@
 	m_reclaim ();
 	if (mmbfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mmbfree == NULL);
+			if (mmbfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
@@ -959,10 +960,19 @@
 	m_reclaim ();
 	if (mclfree == NULL) {
+		int try = 0;
+		int print_limit = 30 * rtems_bsdnet_ticks_per_second;
+
 		mbstat.m_wait++;
-		do {
+		for (;;) {
 			rtems_bsdnet_semaphore_release ();
 			rtems_task_wake_after (1);
 			rtems_bsdnet_semaphore_obtain ();
-		} while (mclfree == NULL);
+			if (mclfree)
+				break;
+			if (++try >= print_limit) {
+				printf ("Still waiting for mbuf cluster.\n");
+				try = 0;
+			}
+		}
 	}
 	else {
