From: Simon Wilkinson Date: Sat, 22 Oct 2011 15:22:36 +0000 (+0100) Subject: rx: New signature for rx event functions X-Git-Tag: openafs-stable-1_8_0pre1~3050 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=be8db58f5a44ce2ee4208de09a5ca1faf6f0f91f rx: New signature for rx event functions For a while now, we've had both new and old-style rx event callback functions. Modify all of our event handlers, and the functions that install them, to use only new style functions, and get rid of the old-style function prototypes. Change-Id: Ic7c568df9d191edb082fb41fb7705c54ca93cf48 Reviewed-on: http://gerrit.openafs.org/5839 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/rx/rx.c b/src/rx/rx.c index b042123..5fb6864 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -101,7 +101,13 @@ static void rxi_ComputeRoundTripTime(struct rx_packet *, struct rx_ackPacket *, static void rxi_Resend(struct rxevent *event, void *arg0, void *arg1, int istack); static void rxi_SendDelayedAck(struct rxevent *event, void *call, - void *dummy); + void *dummy, int dummy2); +static void rxi_SendDelayedCallAbort(struct rxevent *event, void *arg1, + void *dummy, int dummy2); +static void rxi_SendDelayedConnAbort(struct rxevent *event, void *arg1, + void *unused, int unused2); +static void rxi_ReapConnections(struct rxevent *unused, void *unused1, + void *unused2, int unused3); #ifdef RX_ENABLE_LOCKS static void rxi_SetAcksInTransmitQueue(struct rx_call *call); @@ -650,8 +656,8 @@ rxi_rto_startTimer(struct rx_call *call, int lastPacket, int istack) MUTEX_ENTER(&rx_refcnt_mutex); CALL_HOLD(call, RX_CALL_REFCOUNT_RESEND); MUTEX_EXIT(&rx_refcnt_mutex); - call->resendEvent = rxevent_PostNow2(&retryTime, &now, rxi_Resend, - call, 0, istack); + call->resendEvent = rxevent_Post(&retryTime, &now, rxi_Resend, + call, NULL, istack); } /*! @@ -781,9 +787,9 @@ rxi_PostDelayedAckEvent(struct rx_call *call, struct clock *offset) CALL_HOLD(call, RX_CALL_REFCOUNT_DELAY); MUTEX_EXIT(&rx_refcnt_mutex); - call->delayedAckEvent = rxevent_PostNow(&when, &now, - rxi_SendDelayedAck, - call, 0); + call->delayedAckEvent = rxevent_Post(&when, &now, + rxi_SendDelayedAck, + call, NULL, 0); } } @@ -948,7 +954,7 @@ rx_StartServer(int donateMe) } /* Turn on reaping of idle server connections */ - rxi_ReapConnections(NULL, NULL, NULL); + rxi_ReapConnections(NULL, NULL, NULL, 0); USERPRI; @@ -2390,7 +2396,7 @@ rx_EndCall(struct rx_call *call, afs_int32 rc) rxevent_Cancel(call->delayedAckEvent, call, RX_CALL_REFCOUNT_DELAY); call->delayedAckEvent = NULL; - rxi_SendDelayedAck(NULL, call, NULL); + rxi_SendDelayedAck(NULL, call, NULL, 0); } /* We need to release the call lock since it's lower than the @@ -3690,7 +3696,7 @@ rxi_ConnClearAttachWait(struct rx_connection *conn) } static void -rxi_CheckReachEvent(struct rxevent *event, void *arg1, void *arg2) +rxi_CheckReachEvent(struct rxevent *event, void *arg1, void *arg2, int dummy) { struct rx_connection *conn = arg1; struct rx_call *acall = arg2; @@ -3740,9 +3746,9 @@ rxi_CheckReachEvent(struct rxevent *event, void *arg1, void *arg2) MUTEX_ENTER(&rx_refcnt_mutex); conn->refCount++; MUTEX_EXIT(&rx_refcnt_mutex); - conn->checkReachEvent = - rxevent_PostNow(&when, &now, rxi_CheckReachEvent, conn, - NULL); + conn->checkReachEvent = rxevent_Post(&when, &now, + rxi_CheckReachEvent, conn, + NULL, 0); } MUTEX_EXIT(&conn->conn_data_lock); } @@ -3774,7 +3780,7 @@ rxi_CheckConnReach(struct rx_connection *conn, struct rx_call *call) conn->flags |= RX_CONN_ATTACHWAIT; MUTEX_EXIT(&conn->conn_data_lock); if (!conn->checkReachEvent) - rxi_CheckReachEvent(NULL, conn, call); + rxi_CheckReachEvent(NULL, conn, call, 0); return 1; } @@ -4925,7 +4931,8 @@ rxi_AckAll(struct rxevent *event, struct rx_call *call, char *dummy) } void -rxi_SendDelayedAck(struct rxevent *event, void *arg1, void *unused) +rxi_SendDelayedAck(struct rxevent *event, void *arg1, void *unused1, + int unused2) { struct rx_call *call = arg1; #ifdef RX_ENABLE_LOCKS @@ -5086,7 +5093,7 @@ rxi_SendCallAbort(struct rx_call *call, struct rx_packet *packet, CALL_HOLD(call, RX_CALL_REFCOUNT_ABORT); MUTEX_EXIT(&rx_refcnt_mutex); call->delayedAbortEvent = - rxevent_PostNow(&when, &now, rxi_SendDelayedCallAbort, call, 0); + rxevent_Post(&when, &now, rxi_SendDelayedCallAbort, call, 0, 0); } return packet; } @@ -5132,7 +5139,7 @@ rxi_SendConnectionAbort(struct rx_connection *conn, when = now; clock_Addmsec(&when, rxi_connAbortDelay); conn->delayedAbortEvent = - rxevent_PostNow(&when, &now, rxi_SendDelayedConnAbort, conn, 0); + rxevent_Post(&when, &now, rxi_SendDelayedConnAbort, conn, NULL, 0); } return packet; } @@ -6332,7 +6339,8 @@ mtuout: } void -rxi_NatKeepAliveEvent(struct rxevent *event, void *arg1, void *dummy) +rxi_NatKeepAliveEvent(struct rxevent *event, void *arg1, + void *dummy, int dummy2) { struct rx_connection *conn = arg1; struct rx_header theader; @@ -6399,7 +6407,7 @@ rxi_ScheduleNatKeepAliveEvent(struct rx_connection *conn) conn->refCount++; /* hold a reference for this */ MUTEX_EXIT(&rx_refcnt_mutex); conn->natKeepAliveEvent = - rxevent_PostNow(&when, &now, rxi_NatKeepAliveEvent, conn, 0); + rxevent_Post(&when, &now, rxi_NatKeepAliveEvent, conn, NULL, 0); } } @@ -6436,7 +6444,8 @@ rxi_NatKeepAliveOn(struct rx_connection *conn) * keep-alive packet (if we're actually trying to keep the call alive) */ void -rxi_KeepAliveEvent(struct rxevent *event, void *arg1, void *dummy) +rxi_KeepAliveEvent(struct rxevent *event, void *arg1, void *dummy, + int dummy2) { struct rx_call *call = arg1; struct rx_connection *conn; @@ -6479,7 +6488,7 @@ rxi_KeepAliveEvent(struct rxevent *event, void *arg1, void *dummy) /* Does what's on the nameplate. */ void -rxi_GrowMTUEvent(struct rxevent *event, void *arg1, void *dummy) +rxi_GrowMTUEvent(struct rxevent *event, void *arg1, void *dummy, int dummy2) { struct rx_call *call = arg1; struct rx_connection *conn; @@ -6534,7 +6543,7 @@ rxi_ScheduleKeepAliveEvent(struct rx_call *call) CALL_HOLD(call, RX_CALL_REFCOUNT_ALIVE); MUTEX_EXIT(&rx_refcnt_mutex); call->keepAliveEvent = - rxevent_PostNow(&when, &now, rxi_KeepAliveEvent, call, 0); + rxevent_Post(&when, &now, rxi_KeepAliveEvent, call, NULL, 0); } } @@ -6559,7 +6568,7 @@ rxi_ScheduleGrowMTUEvent(struct rx_call *call, int secs) CALL_HOLD(call, RX_CALL_REFCOUNT_ALIVE); MUTEX_EXIT(&rx_refcnt_mutex); call->growMTUEvent = - rxevent_PostNow(&when, &now, rxi_GrowMTUEvent, call, 0); + rxevent_Post(&when, &now, rxi_GrowMTUEvent, call, NULL, 0); } } @@ -6589,8 +6598,8 @@ rxi_GrowMTUOn(struct rx_call *call) /* This routine is called to send connection abort messages * that have been delayed to throttle looping clients. */ void -rxi_SendDelayedConnAbort(struct rxevent *event, - void *arg1, void *unused) +rxi_SendDelayedConnAbort(struct rxevent *event, void *arg1, void *unused, + int unused2) { struct rx_connection *conn = arg1; @@ -6614,9 +6623,9 @@ rxi_SendDelayedConnAbort(struct rxevent *event, /* This routine is called to send call abort messages * that have been delayed to throttle looping clients. */ -void -rxi_SendDelayedCallAbort(struct rxevent *event, - void *arg1, void *dummy) +static void +rxi_SendDelayedCallAbort(struct rxevent *event, void *arg1, void *dummy, + int dummy2) { struct rx_call *call = arg1; @@ -6690,7 +6699,7 @@ rxi_ChallengeEvent(struct rxevent *event, when = now; when.sec += RX_CHALLENGE_TIMEOUT; conn->challengeEvent = - rxevent_PostNow2(&when, &now, rxi_ChallengeEvent, conn, 0, + rxevent_Post(&when, &now, rxi_ChallengeEvent, conn, 0, (tries - 1)); } } @@ -6870,7 +6879,8 @@ rxi_ComputeRoundTripTime(struct rx_packet *p, /* Find all server connections that have not been active for a long time, and * toss them */ void -rxi_ReapConnections(struct rxevent *unused, void *unused1, void *unused2) +rxi_ReapConnections(struct rxevent *unused, void *unused1, void *unused2, + int unused3) { struct clock now, when; clock_GetTime(&now); @@ -7077,7 +7087,7 @@ rxi_ReapConnections(struct rxevent *unused, void *unused1, void *unused2) when = now; when.sec += RX_REAP_TIME; /* Check every RX_REAP_TIME seconds */ - rxevent_Post(&when, rxi_ReapConnections, 0, 0); + rxevent_Post(&when, &now, rxi_ReapConnections, 0, NULL, 0); } diff --git a/src/rx/rx_event.c b/src/rx/rx_event.c index b520f16..6bfbc33 100644 --- a/src/rx/rx_event.c +++ b/src/rx/rx_event.c @@ -197,10 +197,10 @@ rxepoch_Allocate(struct clock *when) * "when" argument specifies when "func" should be called, in clock (clock.h) * units. */ -static struct rxevent * -_rxevent_Post(struct clock *when, struct clock *now, +struct rxevent * +rxevent_Post(struct clock *when, struct clock *now, void (*func) (struct rxevent *, void *, void *, int), - void *arg, void *arg1, int arg2, int newargs) + void *arg, void *arg1, int arg2) { struct rxevent *ev, *evqe, *evqpr; struct rxepoch *ep, *epqe, *epqpr; @@ -291,15 +291,10 @@ _rxevent_Post(struct clock *when, struct clock *now, /* Record user defined event state */ ev->eventTime = *when; - if (newargs) { - ev->func.newfunc = func; - } else { - ev->func.oldfunc = (void (*)(struct rxevent *, void *, void*))func; - } + ev->func = func; ev->arg = arg; ev->arg1 = arg1; ev->arg2 = arg2; - ev->newargs = newargs; rxevent_nPosted += 1; /* Rather than ++, to shut high-C up * regarding never-set variables */ @@ -329,46 +324,6 @@ _rxevent_Post(struct clock *when, struct clock *now, return ev; } -struct rxevent * -rxevent_Post(struct clock *when, - void (*func) (struct rxevent *, void *, void *), - void *arg, void *arg1) -{ - struct clock now; - clock_Zero(&now); - return _rxevent_Post(when, &now, - (void (*)(struct rxevent *, void *, void *, int))func, - arg, arg1, 0, 0); -} - -struct rxevent * -rxevent_Post2(struct clock *when, - void (*func) (struct rxevent *, void *, void *, int), - void *arg, void *arg1, int arg2) -{ - struct clock now; - clock_Zero(&now); - return _rxevent_Post(when, &now, func, arg, arg1, arg2, 1); -} - -struct rxevent * -rxevent_PostNow(struct clock *when, struct clock *now, - void (*func) (struct rxevent *, void *, void *), - void *arg, void *arg1) -{ - return _rxevent_Post(when, now, - (void (*)(struct rxevent *, void *, void *, int))func, - arg, arg1, 0, 0); -} - -struct rxevent * -rxevent_PostNow2(struct clock *when, struct clock *now, - void (*func) (struct rxevent *, void *, void *, int), - void *arg, void *arg1, int arg2) -{ - return _rxevent_Post(when, now, func, arg, arg1, arg2, 1); -} - /* Cancel an event by moving it from the event queue to the free list. * Warning, the event must be on the event queue! If not, this should core * dump (reference through 0). This routine should be called using the macro @@ -392,7 +347,7 @@ rxevent_Cancel_1(struct rxevent *ev, struct rx_call *call, fprintf(rx_Log_event, "%d.%d: rxevent_Cancel_1(%d.%d, %" AFS_PTR_FMT ", %p" AFS_PTR_FMT ")\n", (int)now.sec, (int)now.usec, (int)ev->eventTime.sec, - (int)ev->eventTime.usec, ev->func.newfunc, + (int)ev->eventTime.usec, ev->func, ev->arg); } #endif @@ -480,11 +435,7 @@ rxevent_RaiseEvents(struct clock *next) queue_Remove(ev); rxevent_nPosted--; MUTEX_EXIT(&rxevent_lock); - if (ev->newargs) { - ev->func.newfunc(ev, ev->arg, ev->arg1, ev->arg2); - } else { - ev->func.oldfunc(ev, ev->arg, ev->arg1); - } + ev->func(ev, ev->arg, ev->arg1, ev->arg2); MUTEX_ENTER(&rxevent_lock); queue_Append(&rxevent_free, ev); rxevent_nFree++; diff --git a/src/rx/rx_event.h b/src/rx/rx_event.h index 1d18678..e31d1b4 100644 --- a/src/rx/rx_event.h +++ b/src/rx/rx_event.h @@ -33,14 +33,10 @@ struct rxevent { struct rx_queue junk; /* Events are queued */ struct clock eventTime; /* When this event times out (in clock.c units) */ - union { - void (*oldfunc) (struct rxevent *, void *, void *); - void (*newfunc) (struct rxevent *, void *, void *, int); - } func; /* Function to call when this expires */ + void (*func) (struct rxevent *, void *, void *, int); void *arg; /* Argument to the function */ void *arg1; /* Another argument */ int arg2; /* An integer argument */ - int newargs; /* Nonzero if new-form arguments should be used */ }; /* We used to maintain a sorted list of events, but the amount of CPU diff --git a/src/rx/rx_prototypes.h b/src/rx/rx_prototypes.h index 5473d5c..f07439f 100644 --- a/src/rx/rx_prototypes.h +++ b/src/rx/rx_prototypes.h @@ -148,12 +148,6 @@ extern int rxi_CheckCall(struct rx_call *call, int haveCTLock); #else /* RX_ENABLE_LOCKS */ extern int rxi_CheckCall(struct rx_call *call); #endif /* RX_ENABLE_LOCKS */ -extern void rxi_KeepAliveEvent(struct rxevent *event, - void *call /* struct rx_call *call */, - void *dummy); -extern void rxi_GrowMTUEvent(struct rxevent *event, - void *call /* struct rx_call *call */, - void *dummy); extern void rxi_ScheduleKeepAliveEvent(struct rx_call *call); extern void rxi_ScheduleNatKeepAliveEvent(struct rx_connection *conn); extern void rxi_ScheduleGrowMTUEvent(struct rx_call *call, int secs); @@ -161,18 +155,10 @@ extern void rxi_KeepAliveOn(struct rx_call *call); extern void rxi_NatKeepAliveOn(struct rx_connection *conn); extern void rxi_GrowMTUOn(struct rx_call *call); extern void rx_SetConnSecondsUntilNatPing(struct rx_connection *conn, afs_int32 seconds); -extern void rxi_SendDelayedConnAbort(struct rxevent *event, - void *conn, /* struct rx_connection *conn */ - void *dummy); -extern void rxi_SendDelayedCallAbort(struct rxevent *event, - void *call, /* struct rx_call *call */ - void *dummy); extern void rxi_ChallengeEvent(struct rxevent *event, void *conn, /* struct rx_connection *conn */ void *arg1, int atries); extern void rxi_ChallengeOn(struct rx_connection *conn); -extern void rxi_ReapConnections(struct rxevent *unused, void *unused1, - void *unused2); extern int rxs_Release(struct rx_securityClass *aobj); #ifndef KERNEL extern void rx_PrintTheseStats(FILE * file, struct rx_statistics *s, int size, @@ -297,27 +283,10 @@ extern void rx_ReleaseCachedConnection(struct rx_connection *conn); /* rx_event.c */ extern int rxevent_nFree; extern int rxevent_nPosted; -#if 0 -extern struct rxevent *rxevent_Post(struct clock *when, - void (*func) (struct rxevent * event, - struct rx_connection * conn, - struct rx_call * acall), - void *arg, void *arg1); -/* this func seems to be called with tons of different style routines, need to look -at another time. */ -#else -extern struct rxevent *rxevent_Post(struct clock *when, - void (*func) (struct rxevent *, void *, void *), - void *arg, void *arg1); -extern struct rxevent *rxevent_Post2(struct clock *when, - void (*func) (struct rxevent *, void *, void *, int), - void *arg, void *arg1, int arg2); -extern struct rxevent *rxevent_PostNow(struct clock *when, struct clock *now, - void (*func) (struct rxevent *, void *, void *), void *arg, void *arg1); -extern struct rxevent *rxevent_PostNow2(struct clock *when, struct clock *now, - void (*func) (struct rxevent *, void *, void *, int), void *arg, - void *arg1, int arg2); -#endif +extern struct rxevent *rxevent_Post(struct clock *when, struct clock *now, + void (*func) (struct rxevent *, void *, + void *, int), + void *arg, void *arg1, int arg2); extern void shutdown_rxevent(void); extern struct rxepoch *rxepoch_Allocate(struct clock *when); extern void rxevent_Init(int nEvents, void (*scheduler) (void));