Call getsockname(2) once the connection has succeeded to record the
local socket address in the AsyncSocket struct so that
AsyncSocket_GetLocalVMCIAddress works for sockets using the kernel vsock
driver as well.
This allows me to print the local socket address in vsockTest, which
is useful for debugging.
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
return ASOCKERR_GENERIC;
}
+ s->localAddrLen = sizeof s->localAddr;
+ if (getsockname(s->fd, &s->localAddr, &s->localAddrLen) != 0) {
+ sysErr = ASOCK_LASTERROR();
+ s->genericErrno = sysErr;
+ Warning(ASOCKPREFIX "getsockname for connect on fd %d failed with "
+ "error %d: %s\n", s->fd, sysErr, Err_Errno2String(sysErr));
+
+ return ASOCKERR_GENERIC;
+ }
+
done:
s->state = AsyncSocketConnected;
s->connectFn(s, s->clientData);