Thu, 07 Apr 2005 14:55:02 +0000
[gaim-migrate @ 12431]
" The following log snippets should explain it: " --rlaager
(20:24:00) rlaager: Regarding the signal handling
conversation the other day... I've written a patch to stop
calling signal handlers and return as soon as we find one
signal handler that returns TRUE to indicate that it's
handled the signal. Is this the right approach?
(20:24:22) Ethan Blanton (Paco-Paco): the trouble is that it's
documented to behave exactly the way it does
(20:24:31) Ethan Blanton (Paco-Paco): so changing it is
notbackwards compatible
(20:24:31) rlaager: I'm talking for HEAD.
(20:24:41) Ethan Blanton (Paco-Paco): oh, I think that's a
good approach, yes
(20:24:53) rlaager: The way I've described is how I
*expected* it to work, having not read the documentation.
(20:25:09) Ethan Blanton (Paco-Paco): I'm convinced
(20:27:04) Stu Tomlinson (nosnilmot): rlaager: this, I
assume, breaks the generic-ness of signals, by assuming
that any that return values return booleans?
(20:27:26) Ethan Blanton (Paco-Paco): please break it
(20:27:33) Ethan Blanton (Paco-Paco): we already have
out-parameters
(20:27:42) rlaager: nosnilmot: from what I can see, the
return type is handled as a (void *)... so I'm checking that
ret_value != NULL
(20:27:57) rlaager: nosnilmot: that's the correct way to do it,
right?
...
(20:29:01) Ethan Blanton (Paco-Paco): allowing a
meaningful return value is an over-engineering
(20:30:07) rlaager: even after this patch, you should be able
to return meaningful return values
(20:30:15) rlaager: it'll just short-circuit on the first handler
that does
committer: Luke Schierer <lschiere@pidgin.im>
/* This file is part of the Project Athena Zephyr Notification System. * It contains source for the ZSetLocation, ZUnsetLocation, and * ZFlushMyLocations functions. * * Created by: Robert French * * $Source$ * $Author: thekingant $ * * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file * "mit-copyright.h". */ /* $Header$ */ #ifndef lint static char rcsid_ZLocations_c[] = "$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZLocations.c,v 1.30 90/12/20 03:04:39 raeburn Exp $"; #endif #include "internal.h" #include <pwd.h> extern char *getenv(); extern int errno; Code_t ZSetLocation(exposure) char *exposure; { return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, "$sender logged in to $1 on $3 at $2")); } Code_t ZUnsetLocation() { return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, "$sender logged out of $1 on $3 at $2")); } Code_t ZFlushMyLocations() { return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); } static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN]; static int reenter = 0; Code_t Z_SendLocation(class, opcode, auth, format) char *class; char *opcode; Z_AuthProc auth; char *format; { int retval; time_t ourtime; ZNotice_t notice, retnotice; char *bptr[3], *p; #ifndef X_DISPLAY_MISSING char *display; #endif char *ttyp; struct hostent *hent; short wg_port = ZGetWGPort(); (void) memset((char *)¬ice, 0, sizeof(notice)); notice.z_kind = ACKED; notice.z_port = (unsigned short) ((wg_port == -1) ? 0 : wg_port); notice.z_class = class; notice.z_class_inst = ZGetSender(); notice.z_opcode = opcode; notice.z_sender = 0; notice.z_recipient = ""; notice.z_num_other_fields = 0; notice.z_default_format = format; /* keep track of what we said before so that we can be consistent when changing location information. This is done mainly for the sake of the WindowGram client. */ if (!reenter) { if (gethostname(host, MAXHOSTNAMELEN) < 0) return (errno); hent = gethostbyname(host); if (hent) { (void) strncpy(host, hent->h_name, sizeof(host)); host[sizeof(host) - 1] = '\0'; } #ifndef X_DISPLAY_MISSING if ((display = getenv("DISPLAY")) && *display) { (void) strncpy(mytty, display, sizeof(mytty)); mytty[sizeof(mytty)-1] = '\0'; } else { #endif ttyp = ttyname(0); if (ttyp && *ttyp) { p = strchr(ttyp + 1, '/'); strcpy(mytty, (p) ? p + 1 : ttyp); } else { strcpy(mytty, "unknown"); } #ifndef X_DISPLAY_MISSING } #endif reenter = 1; } ourtime = time((time_t *)0); bptr[0] = host; bptr[1] = ctime(&ourtime); bptr[1][strlen(bptr[1])-1] = '\0'; bptr[2] = mytty; if ((retval = ZSendList(¬ice, bptr, 3, auth)) != ZERR_NONE) return (retval); retval = Z_WaitForNotice (&retnotice, ZCompareUIDPred, ¬ice.z_uid, SRV_TIMEOUT); if (retval != ZERR_NONE) return retval; if (retnotice.z_kind == SERVNAK) { if (!retnotice.z_message_len) { ZFreeNotice(&retnotice); return (ZERR_SERVNAK); } if (!strcmp(retnotice.z_message, ZSRVACK_NOTSENT)) { ZFreeNotice(&retnotice); return (ZERR_AUTHFAIL); } if (!strcmp(retnotice.z_message, ZSRVACK_FAIL)) { ZFreeNotice(&retnotice); return (ZERR_LOGINFAIL); } ZFreeNotice(&retnotice); return (ZERR_SERVNAK); } if (retnotice.z_kind != SERVACK) { ZFreeNotice(&retnotice); return (ZERR_INTERNAL); } if (!retnotice.z_message_len) { ZFreeNotice(&retnotice); return (ZERR_INTERNAL); } if (strcmp(retnotice.z_message, ZSRVACK_SENT) && strcmp(retnotice.z_message, ZSRVACK_NOTSENT)) { ZFreeNotice(&retnotice); return (ZERR_INTERNAL); } ZFreeNotice(&retnotice); return (ZERR_NONE); }