(file) Return to fusd-flag-for-more-data.patch CVS log (file) Jump to this file's LXR Page (dir) Up to [CENS] / emstar / fusd / patches

File: [CENS] / emstar / fusd / patches / fusd-flag-for-more-data.patch (download)
Revision: 1.1, Thu Jan 2 21:43:12 2003 UTC (6 years, 10 months ago) by jelson
Branch: MAIN
CVS Tags: scale_radio_channel, rdd_alpha_version_1, pregeonet, nims-lab-Sep07-2004, nims-jr-Sep05-04, mote, lessgps_release, kiss_release, fusd_with_no_daemon, fusd-1_10, copyright-07-11-03, bp_scale_radio_channel, audio_server, acoustic-05-18-06, ROUTING_EXPERIMENTAL, PRE_TOSNIC_FIX, PRE_NOMEGA_MOTENIC, PRE_MOTENIC_CLEANUP, PRE_CEILING_FIX, PRE_64BIT, MOTENIC_PRE_BUGFIX_20050415, LESSGPS_1_00, LAURA_CALIBRATION_EXPERIMENTS, KISS_1_0, HOSTMOTE_V_6_EXPERIMENTAL, HOSTMOTE_PROTOCOL_VERSION_7, HOSTMOTE_PROTOCOL_VERSION_6_WITH_HOSTMOAP, HOSTMOTE_PROTOCOL_VERSION_5_WITH_HOSTMOAP, HOSTMOTE_PROTOCOL_VERSION_5, HOSTMOTE_PROTOCOL_VERSION_4, HOSTMOTE_PROTOCOL_VERSION_3, HEAD, ESS_RELEASE_3_5, ESS_RELEASE_3_4, ESS_RELEASE_3_3, ESS_RELEASE_3_2, ESS_RELEASE_3_1, ESS_RELEASE_3_0, ESS_RELEASE_2_0, ESS_CONNECTIVITY, ESS_CENTROUTE_TESTING, ESS2-CMS-V1_5_pretest, ESS2-CMS-V1_4cMergeSympathy_2, ESS2-CMS-V1_4c, ESS2-CMS-V1_4b, ESS2-CMS-V1_4a, ESS2-CMS-V1_3, ESS2-CMS-V1_2, ESS2-CMS-V1_1, ESS2-CMS-V1_0, EMSTAR_RELEASE_2_5, EMSTAR_RELEASE_2_1_BRANCH, EMSTAR_RELEASE_2_1, EMSTAR_RELEASE_2_0_beta1, EMSTAR_RELEASE_2_0, EMSTAR_RELEASE_1_3_2, EMSTAR_RELEASE_1_3_1, EMSTAR_RELEASE_1_3, EMSTAR_RELEASE_1_2, EMSTAR_RELEASE_1_1, EMSTAR_RELEASE_1_0, EMSTAR_PRE_HTML, CYCLOPS_RELEASE_CANDIDATE_2_0, CYCLOPS_PRERELEASE_STABLE, CENTROUTE_EMSTAR_SOCKETS, BG_1_0, BANGLADESH_ARSENIC_1_2, BANGLADESH_ARSENIC_1_1, AMARSS_JR_DEPLOYMENT_6_05_07
code i decided not to use

? fusd-flag-for-more-data.patch
Index: fusd/include/fusd_msg.h
===================================================================
RCS file: /home/cvs/cvsroot/cens/fusd/include/fusd_msg.h,v
retrieving revision 1.21
diff -u -r1.21 fusd_msg.h
--- fusd/include/fusd_msg.h	2003/01/02 01:05:47	1.21
+++ fusd/include/fusd_msg.h	2003/01/02 21:29:23
@@ -37,6 +37,10 @@
 
 #define FUSD_FOPS_CALL_DROPREPLY   6 /* call that doesn't want a reply */
 
+/* this bit gets **OR'd** into the cmd if there are more kernel->user
+ * messages waiting */
+#define FUSD_MORE_MESSAGES         (1 << 7)
+
 /* subcommands */
 #define FUSD_OPEN                  100
 #define FUSD_CLOSE                 101
@@ -47,7 +51,7 @@
 #define FUSD_UNBLOCK               106
 
 /* other constants */
-#define FUSD_MSG_MAGIC      0x7a6b93cd
+#define FUSD_MSG_MAGIC      0x7a6b93ce /* version number included :-) */
 
 /* user->kernel: register a device */
 typedef struct {
Index: fusd/kfusd/kfusd.c
===================================================================
RCS file: /home/cvs/cvsroot/cens/fusd/kfusd/kfusd.c,v
retrieving revision 1.88
diff -u -r1.88 kfusd.c
--- fusd/kfusd/kfusd.c	2003/01/02 05:15:46	1.88
+++ fusd/kfusd/kfusd.c	2003/01/02 21:29:23
@@ -1796,16 +1796,20 @@
 
 
 /* do a "header" read: used by fusd_read */
-static int fusd_read_header(char *user_buffer, size_t user_length, fusd_msg_t *msg)
+static int fusd_read_header(char *user_buffer, size_t user_length, fusd_msgC_t *container)
 {
-  int len = sizeof(fusd_msg_t);
-
-  if (user_length != len) {
+  /* sanity check */
+  if (user_length != sizeof(fusd_msg_t)) {
     RDEBUG(4, "bad length of %d sent to /dev/fusd for peek", user_length);
     return -EINVAL;
   }
 
-  if (copy_to_user(user_buffer, msg, len))
+  /* give a hint to the reader as to whether or not they should read
+   * again after this read .. i.e. if there is more data waiting. */
+  if (container->next)
+    container->fusd_msg.cmd |= FUSD_MORE_MESSAGES;
+
+  if (copy_to_user(user_buffer, &container->fusd_msg, sizeof(fusd_msg_t)))
     return -EFAULT;
 
   return sizeof(fusd_msg_t);
@@ -1813,8 +1817,9 @@
 
 
 /* do a "data" read: used by fusd_read */
-static int fusd_read_data(char *user_buffer, size_t user_length, fusd_msg_t *msg)
+static int fusd_read_data(char *user_buffer, size_t user_length, fusd_msgC_t *container)
 {
+  fusd_msg_t *msg = &container->fusd_msg;
   int len = msg->datalen;
 
   if (len == 0 || msg->data == NULL) {
@@ -1881,11 +1886,11 @@
       goto out;
     }
   }
-
+  
   /* is this a header read or data read? */
   if (!msg_out->peeked) {
     /* this is a header read (first read) */
-    retval = fusd_read_header(user_buffer, user_length, &msg_out->fusd_msg);
+    retval = fusd_read_header(user_buffer, user_length, msg_out);
 
     /* is there data?  if so, make sure next read gets data.  if not,
      * make sure message is dequeued now.*/
@@ -1897,7 +1902,7 @@
     }
   } else {
     /* this is a data read (second read) */
-    retval = fusd_read_data(user_buffer, user_length, &msg_out->fusd_msg);
+    retval = fusd_read_data(user_buffer, user_length, msg_out);
     dequeue = 1; /* message should be dequeued */
   }
 
Index: fusd/libfusd/libfusd.c
===================================================================
RCS file: /home/cvs/cvsroot/cens/fusd/libfusd/libfusd.c,v
retrieving revision 1.56
diff -u -r1.56 libfusd.c
--- fusd/libfusd/libfusd.c	2002/12/28 01:42:04	1.56
+++ fusd/libfusd/libfusd.c	2003/01/02 21:29:23
@@ -309,8 +309,11 @@
  * back to the kernel, IF the return value from the callback is not
  * FUSD_NOREPLY.
  *
- * On success, returns 0.
+ * On success, if there are no more messages queued in the kernel, returns 1.
+ * On success, if there are additional messages waiting, returns 0.
  * On failure, returns a negative number indicating the errno.
+ *
+ * Keep reading as long as you are getting 0 as the retval.
  */
 static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
 {
@@ -318,6 +321,7 @@
   fusd_msg_t *msg = NULL;
   int driver_retval = 0; /* returned to the FUSD driver */
   int user_retval = 0;    /* returned to the user who made the syscall */
+  int more_messages = 0;
 
   /* check for valid, look up ops */
   if (fops == NULL) {
@@ -338,6 +342,14 @@
   if ((driver_retval = fusd_get_message(fd, msg)) < 0)
     goto out_noreply;
 
+  /* The kernel turns on a bit in the CMD field if there are more
+   * messages waiting.  If it is set, take note of it, and then clear
+   * it. */
+  if (msg->cmd & FUSD_MORE_MESSAGES) {
+    more_messages = 1;
+    msg->cmd &= ~(FUSD_MORE_MESSAGES); /* clear this bit */
+  }
+
   /* allocate file info struct */
   file = malloc(sizeof(fusd_file_info_t));
   if (NULL == file) {
@@ -460,6 +472,8 @@
   if (driver_retval < 0) {
     errno = -driver_retval;
     driver_retval = -1;
+  } else if (driver_retval == 0 && !more_messages) {
+    driver_retval = 1;
   }
   return driver_retval;
 }
@@ -490,10 +504,7 @@
   /* now keep dispatching until a dispatch returns an error */
   do {
     retval = fusd_dispatch_one(fd, fops);
-
-    if (retval >= 0)
-      num_dispatches++;
-  } while (retval >= 0 && num_dispatches <= MAX_MESSAGES_PER_DISPATCH);
+  } while (!retval && ++num_dispatches <= MAX_MESSAGES_PER_DISPATCH);
 
   /* if we've dispatched at least one message successfully, and then
    * stopped because of EAGAIN - do not report an error.  this is the

CENS CVS Mailing List
Powered by
ViewCVS 0.9.2