[openib-general] sdp_kvec.c
Libor Michalek
libor at topspin.com
Thu Feb 24 12:15:50 PST 2005
On Thu, Feb 24, 2005 at 10:03:39PM +0200, Michael S. Tsirkin wrote:
>
> Quoting r. Libor Michalek <libor at topspin.com>:
> > +/*
> > + * Functions to cancel IOCB requests in a conenctions queues.
> > + */
> > +static int _sdp_desc_q_cancel_lookup_func(struct sdpc_desc *element, void *arg)
> > +{
> > + return ((SDP_DESC_TYPE_IOCB == element->type) ? 0 : -ERANGE);
> > +} /* _sdp_iocb_q_cancel_lookup_func */
>
> What do you say to removing the comments after the closing }?
> Its clearly unnecessary (most functions are, or shall be, short enough
> to see where they end), and increases the code footprint.
> For me, they make the detection of the function end harder rather than
> easier, since I am always looking for a sole }.
OK, I'll stop adding them to new functions, and remove them as I
touch code. If I or anyone else get's ambitious we can strip them
from all the functions.
-Libor
Index: Makefile
===================================================================
--- Makefile (revision 1905)
+++ Makefile (working copy)
@@ -10,7 +10,6 @@
sdp_buff.o \
sdp_rcvd.o \
sdp_sent.o \
- sdp_kvec.o \
sdp_read.o \
sdp_write.o \
sdp_wall.o \
Index: sdp_conn.c
===================================================================
--- sdp_conn.c (revision 1905)
+++ sdp_conn.c (working copy)
@@ -597,6 +597,50 @@
return conn;
} /* sdp_conn_table_lookup */
+/*
+ * Functions to cancel IOCB requests in a conenctions queues.
+ */
+static int _sdp_desc_q_cancel_lookup_func(struct sdpc_desc *element, void *arg)
+{
+ return ((SDP_DESC_TYPE_IOCB == element->type) ? 0 : -ERANGE);
+}
+
+static void _sdp_desc_q_cancel_iocb(struct sdpc_desc_q *table, ssize_t error)
+{
+ struct sdpc_iocb *iocb;
+
+ while (NULL != (iocb = (struct sdpc_iocb *)sdp_desc_q_lookup
+ (table,
+ _sdp_desc_q_cancel_lookup_func,
+ NULL))) {
+
+ sdp_iocb_q_remove(iocb);
+ (void)sdp_iocb_complete(iocb, error);
+ }
+}
+
+void sdp_iocb_q_cancel_all_read(struct sdp_opt *conn, ssize_t error)
+{
+ sdp_iocb_q_cancel(&conn->r_pend, SDP_IOCB_F_ALL, error);
+ sdp_iocb_q_cancel(&conn->r_snk, SDP_IOCB_F_ALL, error);
+
+ _sdp_desc_q_cancel_iocb(&conn->r_src, error);
+}
+
+void sdp_iocb_q_cancel_all_write(struct sdp_opt *conn, ssize_t error)
+{
+ sdp_iocb_q_cancel(&conn->w_src, SDP_IOCB_F_ALL, error);
+
+ _sdp_desc_q_cancel_iocb(&conn->send_queue, error);
+ _sdp_desc_q_cancel_iocb(&conn->w_snk, error);
+}
+
+void sdp_iocb_q_cancel_all(struct sdp_opt *conn, ssize_t error)
+{
+ sdp_iocb_q_cancel_all_read(conn, error);
+ sdp_iocb_q_cancel_all_write(conn, error);
+}
+
/*
* connection allocation/deallocation
*/
Index: sdp_kvec.c
===================================================================
--- sdp_kvec.c (revision 1905)
+++ sdp_kvec.c (working copy)
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-
-#include "sdp_main.h"
-
-/*
- * _sdp_iocb_q_cancel_lookup_func - lookup function for cancelation
- */
-static int _sdp_iocb_q_cancel_lookup_func(struct sdpc_desc *element, void *arg)
-{
- return ((SDP_DESC_TYPE_IOCB == element->type) ? 0 : -ERANGE);
-} /* _sdp_iocb_q_cancel_lookup_func */
-
-/*
- * _sdp_iocb_q_cancel_read_pending - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_read_pending(struct sdp_opt *conn,
- ssize_t error)
-{
- sdp_iocb_q_cancel(&conn->r_pend, SDP_IOCB_F_ALL, error);
-} /* _sdp_iocb_q_cancel_read_pending */
-
-/*
- * _sdp_iocb_q_cancel_read_source - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_read_source(struct sdp_opt *conn, ssize_t error)
-{
- struct sdpc_iocb *iocb;
- int result;
-
- while (NULL != (iocb = (struct sdpc_iocb *) sdp_desc_q_lookup(&conn->r_src,
- _sdp_iocb_q_cancel_lookup_func,
- NULL))) {
- sdp_iocb_q_remove(iocb);
-
- result = sdp_iocb_complete(iocb, error);
- SDP_EXPECT(!(0 > result));
- }
-} /* _sdp_iocb_q_cancel_read_source */
-
-/*
- * _sdp_iocb_q_cancel_read_snk - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_read_snk(struct sdp_opt *conn, ssize_t error)
-{
- sdp_iocb_q_cancel(&conn->r_snk, SDP_IOCB_F_ALL, error);
-} /* _sdp_iocb_q_cancel_read_snk */
-
-/*
- * _sdp_iocb_q_cancel_write_pending - cancel all pending read AIOs
- */
-static void _sdp_iocb_q_cancel_write_pending(struct sdp_opt *conn,
- ssize_t error)
-{
- struct sdpc_iocb *iocb;
- int result;
-
- while (NULL !=
- (iocb =
- (struct sdpc_iocb *) sdp_desc_q_lookup(&conn->send_queue,
- _sdp_iocb_q_cancel_lookup_func,
- NULL))) {
- sdp_iocb_q_remove(iocb);
-
- result = sdp_iocb_complete(iocb, error);
- SDP_EXPECT(!(0 > result));
- }
-} /* _sdp_iocb_q_cancel_write_pending */
-
-/*
- * _sdp_iocb_q_cancel_write_source - cancel all pending source AIOs
- */
-static void _sdp_iocb_q_cancel_write_source(struct sdp_opt *conn,
- ssize_t error)
-{
- sdp_iocb_q_cancel(&conn->w_src, SDP_IOCB_F_ALL, error);
-} /* _sdp_iocb_q_cancel_write_source */
-
-/*
- * _sdp_iocb_q_cancel_write_snk - cancel all pending sink AIOs
- */
-static void _sdp_iocb_q_cancel_write_snk(struct sdp_opt *conn, ssize_t error)
-{
- struct sdpc_iocb *iocb;
- int result;
-
- while (NULL != (iocb = (struct sdpc_iocb *) sdp_desc_q_lookup(&conn->w_snk,
- _sdp_iocb_q_cancel_lookup_func,
- NULL))) {
- sdp_iocb_q_remove(iocb);
-
- result = sdp_iocb_complete(iocb, error);
- SDP_EXPECT(!(0 > result));
- }
-} /* _sdp_iocb_q_cancel_write_snk */
-
-/*
- * sdp_iocb_q_cancel_all_read - cancel all outstanding read AIOs
- */
-void sdp_iocb_q_cancel_all_read(struct sdp_opt *conn, ssize_t error)
-{
- _sdp_iocb_q_cancel_read_pending(conn, error);
- _sdp_iocb_q_cancel_read_snk(conn, error);
- _sdp_iocb_q_cancel_read_source(conn, error);
-} /* sdp_iocb_q_cancel_all_read */
-
-/*
- * sdp_iocb_q_cancel_all_write - cancel all outstanding write AIOs
- */
-void sdp_iocb_q_cancel_all_write(struct sdp_opt *conn, ssize_t error)
-{
- _sdp_iocb_q_cancel_write_pending(conn, error);
- _sdp_iocb_q_cancel_write_source(conn, error);
- _sdp_iocb_q_cancel_write_snk(conn, error);
-} /* sdp_iocb_q_cancel_all_write */
-
-/*
- * sdp_iocb_q_cancel_all - cancel all outstanding AIOs
- */
-void sdp_iocb_q_cancel_all(struct sdp_opt *conn, ssize_t error)
-{
- sdp_iocb_q_cancel_all_read(conn, error);
- sdp_iocb_q_cancel_all_write(conn, error);
-} /* sdp_iocb_q_cancel_all */
More information about the general
mailing list