- Timestamp:
- May 26, 2008, 10:58:52 PM (16 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 91258ca
- Parents:
- 83b2ca6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zephyr.c
r5577606 r02f55dc 17 17 #ifdef HAVE_LIBZEPHYR 18 18 int ret; 19 19 ZNotice_t notice; 20 21 /* Stat the zhm manually, with a shorter timeout */ 22 if ((ret = ZOpenPort(NULL)) != ZERR_NONE) 23 return(ret); 24 25 if ((ret = owl_zhm_stat(¬ice)) != ZERR_NONE) 26 return(ret); 27 28 ZClosePort(); 29 20 30 if ((ret = ZInitialize()) != ZERR_NONE) { 21 31 com_err("owl",ret,"while initializing"); … … 29 39 return(0); 30 40 } 41 42 #ifdef HAVE_LIBZEPHYR 43 #define HM_SVC_FALLBACK htons((unsigned short) 2104) 44 45 /* 46 * Code modified from libzephyr's ZhmStat.c 47 * 48 * Modified to only wait one second to time out if there is no 49 * hostmanager present, rather than a rather excessive 10 seconds. 50 */ 51 Code_t owl_zhm_stat(ZNotice_t *notice) { 52 struct servent *sp; 53 struct sockaddr_in sin; 54 ZNotice_t req; 55 Code_t code; 56 struct timeval tv; 57 fd_set readers; 58 59 (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in)); 60 61 sp = getservbyname(HM_SVCNAME, "udp"); 62 63 sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK; 64 sin.sin_family = AF_INET; 65 66 sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 67 68 (void) memset((char *)&req, 0, sizeof(req)); 69 req.z_kind = STAT; 70 req.z_port = 0; 71 req.z_class = HM_STAT_CLASS; 72 req.z_class_inst = HM_STAT_CLIENT; 73 req.z_opcode = HM_GIMMESTATS; 74 req.z_sender = ""; 75 req.z_recipient = ""; 76 req.z_default_format = ""; 77 req.z_message_len = 0; 78 79 if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) 80 return(code); 81 82 if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) 83 return(code); 84 85 /* Wait up to 1 second for a response. */ 86 FD_ZERO(&readers); 87 FD_SET(ZGetFD(), &readers); 88 tv.tv_sec = 1; 89 tv.tv_usec = 0; 90 code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv); 91 if (code < 0 && errno != EINTR) 92 return(errno); 93 if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0) 94 return(ZERR_HMDEAD); 95 96 return(ZReceiveNotice(notice, (struct sockaddr_in *) 0)); 97 } 98 99 #endif 31 100 32 101 int owl_zephyr_shutdown()
Note: See TracChangeset
for help on using the changeset viewer.