file descriptor double close

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

file descriptor double close

Krzysztof Matczak
Hello everyone


Have you ever spotted  problem with double closing file descriptor when db connection cannot be established ? I'm using unixodbc 2.3.2 with libmyodbc 5.3.2 ANSII driver. I've performed simple test:

1. shut down mysql server
2. simple  test application (open odbc connection on port 49897, create table, do couple of SELECT queries, then SQLDisconnect ) run with  strace shows following calls with doubled close(3) call:

64739 socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
64739 connect(3, {sa_family=AF_INET, sin_port=htons(49897), sin_addr=inet_addr("127.0.0.7")}, 16) = -1 ECONNREFUSED (Connection refused)
64739 close(3) = 0
64739 shutdown(3, 2 /* send and receive */) = -1 EBADF (Bad file descriptor)
64739 close(3) = -1 EBADF (Bad file descriptor)
64739 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
64739 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb61e2a5000
64739 write(1, " Error: [unixODBC][MySQL][ODBC 5"..., 97) = 97
64739 exit_group(-1) = ?

Is this  known issue ?  According to my knowledge the second close is potentially dangerous and this l is currently the main suspect for strange random network connectivity problems in another much bigger app that uses odbc  and some networking. 

I've already discussed this issue with Oracle support (responsible for myodbc driver ), but they blamed unixodbc. 

Thanks in advance for support


BR

Krzysztof









BR


_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support

odbc.ini (414 bytes) Download Attachment
odbcinst.ini (238 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: file descriptor double close

Nick Gorham-2
On 29/08/14 12:55, Krzysztof Matczak wrote:
Hello everyone


Have you ever spotted  problem with double closing file descriptor when db connection cannot be established ? I'm using unixodbc 2.3.2 with libmyodbc 5.3.2 ANSII driver. I've performed simple test:

1. shut down mysql server
2. simple  test application (open odbc connection on port 49897, create table, do couple of SELECT queries, then SQLDisconnect ) run with  strace shows following calls with doubled close(3) call:

64739 socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
64739 connect(3, {sa_family=AF_INET, sin_port=htons(49897), sin_addr=inet_addr("127.0.0.7")}, 16) = -1 ECONNREFUSED (Connection refused)
64739 close(3) = 0
64739 shutdown(3, 2 /* send and receive */) = -1 EBADF (Bad file descriptor)
64739 close(3) = -1 EBADF (Bad file descriptor)
64739 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
64739 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb61e2a5000
64739 write(1, " Error: [unixODBC][MySQL][ODBC 5"..., 97) = 97
64739 exit_group(-1) = ?

Is this  known issue ?  According to my knowledge the second close is potentially dangerous and this l is currently the main suspect for strange random network connectivity problems in another much bigger app that uses odbc  and some networking. 

I've already discussed this issue with Oracle support (responsible for myodbc driver ), but they blamed unixodbc.

That's overly generous of them :-)

AFAIK, unixODBC doesnt open a socket to port 49897, so I don't think I can be closing it once or twice. I would look at the driver in this case.

--
Nick

_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support