OSSP CVS Repository

ossp - Check-in [2333]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2333
Date: 2002-Jul-24 11:36:54 (local)
2002-Jul-24 09:36:54 (UTC)
User:rse
Branch:
Comment: make sure the channel mask on each individual channel is also active
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_channel.c      1.27 -> 1.28     12 inserted, 0 deleted

ossp-pkg/l2/l2_channel.c 1.27 -> 1.28

--- l2_channel.c 2002/01/02 17:07:38     1.27
+++ l2_channel.c 2002/07/24 09:36:54     1.28
@@ -334,6 +334,7 @@
 /* write to channel */
 l2_result_t l2_channel_write(l2_channel_t *ch, l2_level_t level, const char *buf, size_t bufsize)
 {
+    int l, j;
     l2_result_t rv;
     l2_result_t rvD;
     l2_channel_t *chD;
@@ -346,6 +347,17 @@
     if (ch->state != L2_CHSTATE_OPENED)
         return L2_ERR_USE;
 
+    /* make sure only a single level is specified */
+    for (l = level, j = 0; l != 0; l = (l >> 1))
+        if (l & 0x1)
+            j++;
+    if (j != 1)
+        return L2_ERR_ARG;
+
+    /* check whether level mask already stops processing */
+    if (!(ch->levelmask & level))
+        return L2_OK;
+
     /* short circuiting */
     if (bufsize == 0)
         return L2_OK;

CVSTrac 2.0.1