comm.c (102528) | comm.c (110560) |
---|---|
1/* 2 * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 * 9 */ 10 11#include <sm/gen.h> | 1/* 2 * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 * 9 */ 10 11#include <sm/gen.h> |
12SM_RCSID("@(#)$Id: comm.c,v 8.54.2.2 2002/08/16 17:09:13 ca Exp $") | 12SM_RCSID("@(#)$Id: comm.c,v 8.54.2.4 2002/12/03 17:32:45 ca Exp $") |
13 14#include "libmilter.h" 15#include <sm/errstring.h> 16 17#define FD_Z FD_ZERO(&readset); \ 18 FD_SET((unsigned int) sd, &readset); \ 19 FD_ZERO(&excset); \ 20 FD_SET((unsigned int) sd, &excset) --- 29 unchanged lines hidden (view full) --- 50 int ret; 51 int save_errno; 52 char *buf; 53 char data[MILTER_LEN_BYTES + 1]; 54 55 *cmd = '\0'; 56 *rlen = 0; 57 | 13 14#include "libmilter.h" 15#include <sm/errstring.h> 16 17#define FD_Z FD_ZERO(&readset); \ 18 FD_SET((unsigned int) sd, &readset); \ 19 FD_ZERO(&excset); \ 20 FD_SET((unsigned int) sd, &excset) --- 29 unchanged lines hidden (view full) --- 50 int ret; 51 int save_errno; 52 char *buf; 53 char data[MILTER_LEN_BYTES + 1]; 54 55 *cmd = '\0'; 56 *rlen = 0; 57 |
58 if (sd >= FD_SETSIZE) 59 { 60 smi_log(SMI_LOG_ERR, "%s: fd %d is larger than FD_SETSIZE %d", 61 name, sd, FD_SETSIZE); 62 *cmd = SMFIC_SELECT; 63 return NULL; 64 } 65 | |
66 i = 0; 67 for (;;) 68 { 69 FD_Z; 70 ret = select(sd + 1, &readset, NULL, &excset, timeout); 71 if (ret == 0) 72 break; 73 else if (ret < 0) --- 8 unchanged lines hidden (view full) --- 82 return NULL; 83 } 84 85 len = MI_SOCK_READ(sd, data + i, sizeof data - i); 86 if (MI_SOCK_READ_FAIL(len)) 87 { 88 smi_log(SMI_LOG_ERR, 89 "%s, mi_rd_cmd: read returned %d: %s", | 58 i = 0; 59 for (;;) 60 { 61 FD_Z; 62 ret = select(sd + 1, &readset, NULL, &excset, timeout); 63 if (ret == 0) 64 break; 65 else if (ret < 0) --- 8 unchanged lines hidden (view full) --- 74 return NULL; 75 } 76 77 len = MI_SOCK_READ(sd, data + i, sizeof data - i); 78 if (MI_SOCK_READ_FAIL(len)) 79 { 80 smi_log(SMI_LOG_ERR, 81 "%s, mi_rd_cmd: read returned %d: %s", |
90 name, len, sm_errstring(errno)); | 82 name, (int) len, sm_errstring(errno)); |
91 *cmd = SMFIC_RECVERR; 92 return NULL; 93 } 94 if (len == 0) 95 { 96 *cmd = SMFIC_EOF; 97 return NULL; 98 } --- 56 unchanged lines hidden (view full) --- 155 free(buf); 156 return NULL; 157 } 158 len = MI_SOCK_READ(sd, buf + i, expl - i); 159 if (MI_SOCK_READ_FAIL(len)) 160 { 161 smi_log(SMI_LOG_ERR, 162 "%s: mi_rd_cmd: read returned %d: %s", | 83 *cmd = SMFIC_RECVERR; 84 return NULL; 85 } 86 if (len == 0) 87 { 88 *cmd = SMFIC_EOF; 89 return NULL; 90 } --- 56 unchanged lines hidden (view full) --- 147 free(buf); 148 return NULL; 149 } 150 len = MI_SOCK_READ(sd, buf + i, expl - i); 151 if (MI_SOCK_READ_FAIL(len)) 152 { 153 smi_log(SMI_LOG_ERR, 154 "%s: mi_rd_cmd: read returned %d: %s", |
163 name, len, sm_errstring(errno)); | 155 name, (int) len, sm_errstring(errno)); |
164 ret = -1; 165 break; 166 } 167 if (len == 0) 168 { 169 *cmd = SMFIC_EOF; 170 free(buf); 171 return NULL; --- 47 unchanged lines hidden (view full) --- 219** len -- length of buffer (without cmd!) 220** 221** Returns: 222** MI_SUCCESS/MI_FAILURE 223*/ 224 225/* 226** we don't care much about the timeout here, it's very long anyway | 156 ret = -1; 157 break; 158 } 159 if (len == 0) 160 { 161 *cmd = SMFIC_EOF; 162 free(buf); 163 return NULL; --- 47 unchanged lines hidden (view full) --- 211** len -- length of buffer (without cmd!) 212** 213** Returns: 214** MI_SUCCESS/MI_FAILURE 215*/ 216 217/* 218** we don't care much about the timeout here, it's very long anyway |
227** FD_SETSIZE is only checked in mi_rd_cmd. | 219** FD_SETSIZE is checked when socket is created. |
228** XXX l == 0 ? 229*/ 230 231#define MI_WR(data) \ 232 while (sl > 0) \ 233 { \ 234 FD_ZERO(&wrtset); \ 235 FD_SET((unsigned int) sd, &wrtset); \ --- 57 unchanged lines hidden --- | 220** XXX l == 0 ? 221*/ 222 223#define MI_WR(data) \ 224 while (sl > 0) \ 225 { \ 226 FD_ZERO(&wrtset); \ 227 FD_SET((unsigned int) sd, &wrtset); \ --- 57 unchanged lines hidden --- |