diff options
| author | Andreas Schwab | 1999-09-14 08:33:24 +0000 |
|---|---|---|
| committer | Andreas Schwab | 1999-09-14 08:33:24 +0000 |
| commit | 5684cd6e1b754889c9c4f8b04c1a46ab78240b57 (patch) | |
| tree | 450a63867d46011b18c370499ef4fa42de8cc4ef /src | |
| parent | 38a734b86bd17fe7296a6bd7d1b0df841d1d5cd6 (diff) | |
| download | emacs-5684cd6e1b754889c9c4f8b04c1a46ab78240b57.tar.gz emacs-5684cd6e1b754889c9c4f8b04c1a46ab78240b57.zip | |
(Fopen_network_stream): Avoid socket decriptor leak.
Diffstat (limited to 'src')
| -rw-r--r-- | src/process.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/process.c b/src/process.c index a67aeb329f6..05cb58b5972 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1834,6 +1834,7 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ | |||
| 1834 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1834 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 1835 | int retry = 0; | 1835 | int retry = 0; |
| 1836 | int count = specpdl_ptr - specpdl; | 1836 | int count = specpdl_ptr - specpdl; |
| 1837 | int count1; | ||
| 1837 | 1838 | ||
| 1838 | #ifdef WINDOWSNT | 1839 | #ifdef WINDOWSNT |
| 1839 | /* Ensure socket support is loaded if available. */ | 1840 | /* Ensure socket support is loaded if available. */ |
| @@ -1899,6 +1900,10 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ | |||
| 1899 | immediate_quit = 0; | 1900 | immediate_quit = 0; |
| 1900 | } | 1901 | } |
| 1901 | 1902 | ||
| 1903 | s = -1; | ||
| 1904 | count1 = specpdl_ptr - specpdl; | ||
| 1905 | record_unwind_protect (close_file_unwind, make_number (s)); | ||
| 1906 | |||
| 1902 | for (lres = res; lres; lres = lres->ai_next) | 1907 | for (lres = res; lres; lres = lres->ai_next) |
| 1903 | { | 1908 | { |
| 1904 | s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); | 1909 | s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); |
| @@ -1984,6 +1989,9 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ | |||
| 1984 | if (s < 0) | 1989 | if (s < 0) |
| 1985 | report_file_error ("error creating socket", Fcons (name, Qnil)); | 1990 | report_file_error ("error creating socket", Fcons (name, Qnil)); |
| 1986 | 1991 | ||
| 1992 | count1 = specpdl_ptr - specpdl; | ||
| 1993 | record_unwind_protect (close_file_unwind, make_number (s)); | ||
| 1994 | |||
| 1987 | /* Kernel bugs (on Ultrix at least) cause lossage (not just EINTR) | 1995 | /* Kernel bugs (on Ultrix at least) cause lossage (not just EINTR) |
| 1988 | when connect is interrupted. So let's not let it get interrupted. | 1996 | when connect is interrupted. So let's not let it get interrupted. |
| 1989 | Note we do not turn off polling, because polling is only used | 1997 | Note we do not turn off polling, because polling is only used |
| @@ -2017,6 +2025,9 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ | |||
| 2017 | goto loop; | 2025 | goto loop; |
| 2018 | } | 2026 | } |
| 2019 | 2027 | ||
| 2028 | /* Discard the unwind protect. */ | ||
| 2029 | specpdl_ptr = specpdl + count1; | ||
| 2030 | |||
| 2020 | close (s); | 2031 | close (s); |
| 2021 | 2032 | ||
| 2022 | if (interrupt_input) | 2033 | if (interrupt_input) |
| @@ -2030,6 +2041,9 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ | |||
| 2030 | 2041 | ||
| 2031 | immediate_quit = 0; | 2042 | immediate_quit = 0; |
| 2032 | 2043 | ||
| 2044 | /* Discard the unwind protect. */ | ||
| 2045 | specpdl_ptr = specpdl + count1; | ||
| 2046 | |||
| 2033 | #ifdef POLL_FOR_INPUT | 2047 | #ifdef POLL_FOR_INPUT |
| 2034 | unbind_to (count, Qnil); | 2048 | unbind_to (count, Qnil); |
| 2035 | #endif | 2049 | #endif |