connect(2) returns EINPROGRESS for "239.10.20.30" which is supposed to

be an unroutable address. getsockopt() to find the actual error returns
0. This is prolly broken, but this temporary work-around fixes the regression
test.
This commit is contained in:
christos 2013-04-12 19:41:45 +00:00
parent 5dd13d5b75
commit a79378684d
1 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: evutil.c,v 1.2 2013/04/11 16:56:41 christos Exp $ */
/* $NetBSD: evutil.c,v 1.3 2013/04/12 19:41:45 christos Exp $ */
/*
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
*
@ -27,7 +27,7 @@
#include "event2/event-config.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: evutil.c,v 1.2 2013/04/11 16:56:41 christos Exp $");
__RCSID("$NetBSD: evutil.c,v 1.3 2013/04/12 19:41:45 christos Exp $");
#define _GNU_SOURCE
@ -483,6 +483,15 @@ evutil_socket_connect(evutil_socket_t *fd_ptr, struct sockaddr *sa, int socklen)
if (connect(*fd_ptr, sa, socklen) < 0) {
int e = evutil_socket_geterror(*fd_ptr);
#ifdef __NetBSD__
if (e == EINPROGRESS) {
socklen_t l = sizeof(e);
l = sizeof(e);
if (getsockopt(*fd_ptr, SOL_SOCKET, SO_ERROR,
(void*)&e, &l) == -1)
abort();
}
#endif
if (EVUTIL_ERR_CONNECT_RETRIABLE(e))
return 0;
if (EVUTIL_ERR_CONNECT_REFUSED(e))