I have a small c program that is supposed to run a select query against a
MySQL database. It keeps bombing with a segfault during what I think is the
db connect. I recompiled everything with debug and ran mysql_debug in the
code and am getting the following:
[youngd@fett]:~/src/logit $ ./searchlog -d
Debug set
Parsed config file and got:
DB Host: fett
DB Name: CHANGELOG
DB User: youngd
DB Pass: xxxxxx
1: dbug: libmysql.c: 1176: 1: >mysql_real_connect
2: dbug: libmysql.c: 1178: 1: | enter: host: fett db: CHANGELOG
user: youngd
3: dbug: libmysql.c: 1294: 1: | info: Server name: 'fett'. TCP
sock: 1073830556
4: dbug: violite.c: 103: 2: | >vio_new
5: dbug: violite.c: 104: 2: | | enter: sd=3
6: dbug: my_malloc.c: 31: 3: | | >my_malloc
7: dbug: my_malloc.c: 32: 3: | | | my: Size: 84 MyFlags: 16
8: dbug: my_malloc.c: 48: 3: | | | exit: ptr: 8072d68
9: dbug: my_malloc.c: 49: 3: | | <my_malloc
10: dbug: violite.c: 126: 2: | <vio_new
11: dbug: libmysql.c: 1346: 1: | error: Got error 111 on connect
to 'fett'
12: dbug: libmysql.c: 1568: 1: | error: message: 2003 (Can't
connect to MySQL server on 'fett' (111))
13: dbug: libmysql.c: 622: 2: | >end_server
14: dbug: libmysql.c: 626: 2: | | info: Net: TCP/IP (3)
15: dbug: violite.c: 341: 3: | | >vio_close
16: dbug: violite.c: 362: 3: | | | vio_error: close() failed,
error: 107
17: dbug: violite.c: 367: 3: | | <vio_close
18: dbug: my_malloc.c: 58: 3: | | >my_free
19: dbug: my_malloc.c: 59: 3: | | | my: ptr: 8072d68
20: dbug: my_malloc.c: 62: 3: | | <my_free
21: dbug: my_malloc.c: 58: 3: | | >my_free
22: dbug: my_malloc.c: 59: 3: | | | my: ptr: 333a3630
Segmentation fault
If I run a strace on the same binary I get:
connect(3, {sin_family=AF_INET, sin_port=htons(23196),
sin_addr=inet_addr("192.168.5.3")}}, 16) = -1 ECONNREFUSED (Connection
refused)
shutdown(3, 2 /* send and receive */) = -1 ENOTCONN (Transport endpoint is
not connected)
close(3) = 0
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++
It picks up the connection info from a config file. I have other utils that
use the same config file and parsing code which work ok. The host, db,
username and password are used by other scripts and programs. The only thing
this program does is runs a single select query against the db.
Any ideas what error 111 and/or 2003 is? Other thoughts?
The actual debug used in the code is:
mysql_debug("d:t:F:L:n:N:P:o:, /tmp/client.trace");
Thanks,
Darren Young
[EMAIL PROTECTED]
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php