Differences From Artifact [2daf8ca68b]:
- File src/OFStream.m — part of check-in [afb42d363d] at 2015-01-19 22:29:17 on branch trunk — OFStream: writeBufferEnabled -> writeBuffered (user: js, size: 30639) [annotate] [blame] [check-ins using]
To Artifact [298e596b16]:
- File
src/OFStream.m
— part of check-in
[62e2de30b9]
at
2015-02-16 08:39:17
on branch trunk
— Explicitly pass errno to exceptions
The old behaviour where the exception would access errno directly on
creation of the exception was very fragile. The two main problems with
it were that sometimes it would pick up an errno even though none had
been set and in other cases that when the exception was created errno
had already been overridden.This also greatly increases errno handling on Win32, especially in
conjunction with sockets. It can still be improved further, though. (user: js, size: 30737) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 | * file. */ #define __NO_EXT_QNX #include "config.h" #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> | > > < < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * file. */ #define __NO_EXT_QNX #include "config.h" #include <assert.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #ifndef _WIN32 # include <signal.h> #endif #import "OFStream.h" |
︙ | ︙ | |||
1482 1483 1484 1485 1486 1487 1488 | readFlags = fcntl([self fileDescriptorForReading], F_GETFL); readImplemented = true; if (readFlags == -1) @throw [OFSetOptionFailedException | | > | > | > | > | 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 | readFlags = fcntl([self fileDescriptorForReading], F_GETFL); readImplemented = true; if (readFlags == -1) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: errno]; if (enable) readFlags &= ~O_NONBLOCK; else readFlags |= O_NONBLOCK; if (fcntl([self fileDescriptorForReading], F_SETFL, readFlags) == -1) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: errno]; } @catch (OFNotImplementedException *e) { } @try { int writeFlags; writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL); writeImplemented = true; if (writeFlags == -1) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: errno]; if (enable) writeFlags &= ~O_NONBLOCK; else writeFlags |= O_NONBLOCK; if (fcntl([self fileDescriptorForWriting], F_SETFL, writeFlags) == -1) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: errno]; } @catch (OFNotImplementedException *e) { } if (!readImplemented && !writeImplemented) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; |
︙ | ︙ |