]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
lsatt: Do not print "no matches" message unconditionally.
authorAndre Noll <maan@systemlinux.org>
Fri, 20 Jan 2012 21:42:39 +0000 (22:42 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 20 Jan 2012 21:42:39 +0000 (22:42 +0100)
com_lsatt() needs to know if output has been sent to the client in
order to decide whether it should print the "no matches" error message.
Currently this message is printed if at least one argument was given
and send_callback_request() returned zero.

However, send_callback_request() returns zero on success and negative
on errors. Hence, if at least one argument was given, the error
message is printed regardless of whether there was a match.

Fix this bug by changing send_callback_request() to return the number
of received shared memory areas on success.

afs.c

diff --git a/afs.c b/afs.c
index 9ef44d7bba82f44b4a615ed5144d7239b0e7218c..263f1818a2763522fd04bacbc153ccdaffce1f35 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -192,7 +192,7 @@ static int dispatch_result(int result_shmid, callback_result_handler *handler,
  * shmid are passed to that function as an osl object. The private_result_data
  * pointer is passed as the second argument to \a result_handler.
  *
  * shmid are passed to that function as an osl object. The private_result_data
  * pointer is passed as the second argument to \a result_handler.
  *
- * \return Standard.
+ * \return Number of shared memory areas dispatched on success, negative on errors.
  *
  * \sa send_option_arg_callback_request(), send_standard_callback_request().
  */
  *
  * \sa send_option_arg_callback_request(), send_standard_callback_request().
  */
@@ -205,7 +205,7 @@ int send_callback_request(callback_function *f, struct osl_object *query,
        void *query_shm;
        char buf[sizeof(afs_socket_cookie) + sizeof(int)];
        size_t query_shm_size = sizeof(*cq);
        void *query_shm;
        char buf[sizeof(afs_socket_cookie) + sizeof(int)];
        size_t query_shm_size = sizeof(*cq);
-       int dispatch_error = 0;
+       int dispatch_error = 0, num_dispatched = 0;
 
        if (query)
                query_shm_size += query->size;
 
        if (query)
                query_shm_size += query->size;
@@ -261,6 +261,7 @@ int send_callback_request(callback_function *f, struct osl_object *query,
                if (ret < 0)
                        PARA_CRIT_LOG("destroy result failed: %s\n",
                                para_strerror(-ret));
                if (ret < 0)
                        PARA_CRIT_LOG("destroy result failed: %s\n",
                                para_strerror(-ret));
+               num_dispatched++;
        }
 out:
        if (shm_destroy(query_shmid) < 0)
        }
 out:
        if (shm_destroy(query_shmid) < 0)
@@ -268,7 +269,7 @@ out:
        if (fd >= 0)
                close(fd);
 //     PARA_DEBUG_LOG("callback_ret: %d\n", ret);
        if (fd >= 0)
                close(fd);
 //     PARA_DEBUG_LOG("callback_ret: %d\n", ret);
-       return ret;
+       return ret < 0? ret : num_dispatched;
 }
 
 /**
 }
 
 /**