diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/process.c b/src/process.c index ebaaf33e57f..4d96e469767 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3331,11 +3331,9 @@ static void | |||
| 3331 | connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | 3331 | connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, |
| 3332 | Lisp_Object use_external_socket_p) | 3332 | Lisp_Object use_external_socket_p) |
| 3333 | { | 3333 | { |
| 3334 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 3335 | int s = -1, outch, inch; | 3334 | int s = -1, outch, inch; |
| 3336 | int xerrno = 0; | 3335 | int xerrno = 0; |
| 3337 | int family; | 3336 | int family; |
| 3338 | struct sockaddr *sa = NULL; | ||
| 3339 | int ret; | 3337 | int ret; |
| 3340 | ptrdiff_t addrlen UNINIT; | 3338 | ptrdiff_t addrlen UNINIT; |
| 3341 | struct Lisp_Process *p = XPROCESS (proc); | 3339 | struct Lisp_Process *p = XPROCESS (proc); |
| @@ -3354,6 +3352,11 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3354 | /* Do this in case we never enter the while-loop below. */ | 3352 | /* Do this in case we never enter the while-loop below. */ |
| 3355 | s = -1; | 3353 | s = -1; |
| 3356 | 3354 | ||
| 3355 | struct sockaddr *sa = NULL; | ||
| 3356 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 3357 | record_unwind_protect_nothing (); | ||
| 3358 | ptrdiff_t count1 = SPECPDL_INDEX (); | ||
| 3359 | |||
| 3357 | while (!NILP (addrinfos)) | 3360 | while (!NILP (addrinfos)) |
| 3358 | { | 3361 | { |
| 3359 | Lisp_Object addrinfo = XCAR (addrinfos); | 3362 | Lisp_Object addrinfo = XCAR (addrinfos); |
| @@ -3366,9 +3369,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3366 | #endif | 3369 | #endif |
| 3367 | 3370 | ||
| 3368 | addrlen = get_lisp_to_sockaddr_size (ip_address, &family); | 3371 | addrlen = get_lisp_to_sockaddr_size (ip_address, &family); |
| 3369 | if (sa) | 3372 | sa = xrealloc (sa, addrlen); |
| 3370 | free (sa); | 3373 | set_unwind_protect_ptr (count, xfree, sa); |
| 3371 | sa = xmalloc (addrlen); | ||
| 3372 | conv_lisp_to_sockaddr (family, ip_address, sa, addrlen); | 3374 | conv_lisp_to_sockaddr (family, ip_address, sa, addrlen); |
| 3373 | 3375 | ||
| 3374 | s = socket_to_use; | 3376 | s = socket_to_use; |
| @@ -3530,7 +3532,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3530 | #endif /* !WINDOWSNT */ | 3532 | #endif /* !WINDOWSNT */ |
| 3531 | 3533 | ||
| 3532 | /* Discard the unwind protect closing S. */ | 3534 | /* Discard the unwind protect closing S. */ |
| 3533 | specpdl_ptr = specpdl + count; | 3535 | specpdl_ptr = specpdl + count1; |
| 3534 | emacs_close (s); | 3536 | emacs_close (s); |
| 3535 | s = -1; | 3537 | s = -1; |
| 3536 | if (0 <= socket_to_use) | 3538 | if (0 <= socket_to_use) |
| @@ -3601,6 +3603,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3601 | Lisp_Object data = get_file_errno_data (err, contact, xerrno); | 3603 | Lisp_Object data = get_file_errno_data (err, contact, xerrno); |
| 3602 | 3604 | ||
| 3603 | pset_status (p, list2 (Fcar (data), Fcdr (data))); | 3605 | pset_status (p, list2 (Fcar (data), Fcdr (data))); |
| 3606 | unbind_to (count, Qnil); | ||
| 3604 | return; | 3607 | return; |
| 3605 | } | 3608 | } |
| 3606 | 3609 | ||
| @@ -3620,7 +3623,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3620 | p->outfd = outch; | 3623 | p->outfd = outch; |
| 3621 | 3624 | ||
| 3622 | /* Discard the unwind protect for closing S, if any. */ | 3625 | /* Discard the unwind protect for closing S, if any. */ |
| 3623 | specpdl_ptr = specpdl + count; | 3626 | specpdl_ptr = specpdl + count1; |
| 3624 | 3627 | ||
| 3625 | if (p->is_server && p->socktype != SOCK_DGRAM) | 3628 | if (p->is_server && p->socktype != SOCK_DGRAM) |
| 3626 | pset_status (p, Qlisten); | 3629 | pset_status (p, Qlisten); |
| @@ -3681,6 +3684,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3681 | } | 3684 | } |
| 3682 | #endif | 3685 | #endif |
| 3683 | 3686 | ||
| 3687 | unbind_to (count, Qnil); | ||
| 3684 | } | 3688 | } |
| 3685 | 3689 | ||
| 3686 | /* Create a network stream/datagram client/server process. Treated | 3690 | /* Create a network stream/datagram client/server process. Treated |