[unixODBC-support] file descriptor double close

Nick Gorham nick at lurcher.org
Fri Aug 29 13:17:05 BST 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20140829/28b603a9/attachment.html>


More information about the unixODBC-support mailing list