|
Lines 1193-1199
main(int argc, char **argv)
Link Here
|
| 1193 |
int in, out, max, ch, skipargs = 0, log_stderr = 0; |
1193 |
int in, out, max, ch, skipargs = 0, log_stderr = 0; |
| 1194 |
ssize_t len, olen, set_size; |
1194 |
ssize_t len, olen, set_size; |
| 1195 |
SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; |
1195 |
SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; |
| 1196 |
char *cp; |
1196 |
char *cp, buf[4*4096]; |
| 1197 |
|
1197 |
|
| 1198 |
extern char *optarg; |
1198 |
extern char *optarg; |
| 1199 |
extern char *__progname; |
1199 |
extern char *__progname; |
|
Lines 1271-1277
main(int argc, char **argv)
Link Here
|
| 1271 |
memset(rset, 0, set_size); |
1271 |
memset(rset, 0, set_size); |
| 1272 |
memset(wset, 0, set_size); |
1272 |
memset(wset, 0, set_size); |
| 1273 |
|
1273 |
|
| 1274 |
FD_SET(in, rset); |
1274 |
/* |
|
|
1275 |
* Ensure that we can read a full buffer and handle |
| 1276 |
* the worst-case length packet it can generate, |
| 1277 |
* otherwise apply backpressure by stopping reads. |
| 1278 |
*/ |
| 1279 |
if (buffer_check_alloc(&iqueue, sizeof(buf)) && |
| 1280 |
buffer_check_alloc(&oqueue, SFTP_MAX_MSG_LENGTH + 4)) |
| 1281 |
FD_SET(in, rset); |
| 1282 |
|
| 1275 |
olen = buffer_len(&oqueue); |
1283 |
olen = buffer_len(&oqueue); |
| 1276 |
if (olen > 0) |
1284 |
if (olen > 0) |
| 1277 |
FD_SET(out, wset); |
1285 |
FD_SET(out, wset); |
|
Lines 1285-1291
main(int argc, char **argv)
Link Here
|
| 1285 |
|
1293 |
|
| 1286 |
/* copy stdin to iqueue */ |
1294 |
/* copy stdin to iqueue */ |
| 1287 |
if (FD_ISSET(in, rset)) { |
1295 |
if (FD_ISSET(in, rset)) { |
| 1288 |
char buf[4*4096]; |
|
|
| 1289 |
len = read(in, buf, sizeof buf); |
1296 |
len = read(in, buf, sizeof buf); |
| 1290 |
if (len == 0) { |
1297 |
if (len == 0) { |
| 1291 |
debug("read eof"); |
1298 |
debug("read eof"); |
|
Lines 1307-1313
main(int argc, char **argv)
Link Here
|
| 1307 |
buffer_consume(&oqueue, len); |
1314 |
buffer_consume(&oqueue, len); |
| 1308 |
} |
1315 |
} |
| 1309 |
} |
1316 |
} |
| 1310 |
/* process requests from client */ |
1317 |
|
| 1311 |
process(); |
1318 |
/* |
|
|
1319 |
* Process requests from client if we can fit the results |
| 1320 |
* into the output buffer, otherwise stop processing input |
| 1321 |
* and let the output queue drain. |
| 1322 |
*/ |
| 1323 |
if (buffer_check_alloc(&oqueue, SFTP_MAX_MSG_LENGTH + 4)) |
| 1324 |
process(); |
| 1312 |
} |
1325 |
} |
| 1313 |
} |
1326 |
} |