UNABLE TO CONNECT TO MYSQL

From: Biswajit Paul <biswajit@dont-contact.us>
Date: Fri, 12 Mar 2004 12:38:10 +0530 (IST)

Hi

    I am plugging MySql support to Squid access Log.
I connected to MySql Server using MySql C-API's.I
modified the "accessLogSquid" Function in
"src/access_log.c" File.Its working fine when runs in
non daemon mode.

   PROBLEM : When Squid is run in "Daemon Mode" its

             UNABLE TO CONNECT TO MYSQL SERVER "

   MY CODE :

------------- src/access_log.c ----------------------

/* global variable */

static MYSQL mysql;

  static void accessLogSquid(AccessLogEntry * al){

                     .
                     .
                     .

      /* Logging to MYSql Database */

        mysql_CONNECT();

                     .
                     .
                     .

         mysql_close(&mysql);
    }

int mysql_CONNECT(){

        char host[20];
        char db[6]="SQUID";
        char usedb[10]="USE SQUID";

        gethostname(host,20);

        mysql_init(&mysql);

        mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"squid");

        if(!mysql_real_connect(&mysql,"","","",db,0,NULL,0)){

          if(!mysql_real_connect(&mysql,host,"","",db,0,NULL,0)){
                debug(1, 1) ("\n Error: %s\n",mysql_error(&mysql));
                mysql_close(&mysql);
                return 0;
              }
           }

if(mysql_query(&mysql,usedb)){
         debug(1, 1) ("\n Error: %s\n",mysql_error(&mysql));
         mysql_close(&mysql);
         return(0);
      }

  return 0;

   }

   CAN ANY ONE FIGURE OUT THE PROBLEM ????
Received on Fri Mar 12 2004 - 00:41:00 MST

This archive was generated by hypermail pre-2.1.9 : Thu Apr 01 2004 - 12:00:04 MST