C
crowl
I have written a program which logs to mysql database. Error routines
should handle the worst case if something goes wrong. In my tests I get
a segmentation fault if I stop the mysql database (stopping after the
mysql connection was successfully). It breaks at this line:
iErr=mysql_errno(&f->f_hmysql);
Here the mysql_query call and the code of the error handling:
/* query */
dprintf("try to call mysql_query ...\n");
if(mysql_query(&f->f_hmysql, psz)) {
int iErr=0;
dprintf("in error handler\n");
iErr=mysql_errno(&f->f_hmysql);
dprintf("mysql insert failed. ErrNo: %n\n", iErr);
}
else {
dprintf("db insert sucessfully\n");
}
dprintf("...after mysql_query.\n");
Any idea how to avoid the segmentation fault? I'm using gcc on a debian
machine.
Thanks for help.
should handle the worst case if something goes wrong. In my tests I get
a segmentation fault if I stop the mysql database (stopping after the
mysql connection was successfully). It breaks at this line:
iErr=mysql_errno(&f->f_hmysql);
Here the mysql_query call and the code of the error handling:
/* query */
dprintf("try to call mysql_query ...\n");
if(mysql_query(&f->f_hmysql, psz)) {
int iErr=0;
dprintf("in error handler\n");
iErr=mysql_errno(&f->f_hmysql);
dprintf("mysql insert failed. ErrNo: %n\n", iErr);
}
else {
dprintf("db insert sucessfully\n");
}
dprintf("...after mysql_query.\n");
Any idea how to avoid the segmentation fault? I'm using gcc on a debian
machine.
Thanks for help.