Roel,

Here's a diff that has a pair of #ifndef blocks in it, one for pgsql and
one for mysql, so that if DBMail is set to use the same connection for db
and for auth, then the auth_connect() and auth_disconnect() functions will
simply return 0, but if the connections are separate, then they will open
up a new link to the database. This should provide the infrastructure
required to add an auth_connect() along with every db_connect() call
without making a mess of the same connection status.

Aaron
*** dbmail-1.0/pgsql/dbauthpgsql.c      Tue Dec  3 08:32:16 2002
--- dbmail-1.0-authldap/pgsql/dbauthpgsql.c     Sun Dec 15 13:13:52 2002
***************
*** 47,52 ****
--- 47,53 ----
   */
  int auth_connect ()
  {
+ #ifndef DBMAIL_USE_SAME_CONNECTION
    char connectionstring[255];
  
    /* connecting */
***************
*** 62,74 ****
--- 63,78 ----
      }
  
    /* database connection OK */  
+ #endif
    return 0;
  }
  
  
  int auth_disconnect()
  {
+ #ifndef DBMAIL_USE_SAME_CONNECTION
    PQfinish(__auth_conn);
+ #endif
    return 0;
  }
  
*** dbmail-1.0/mysql/dbauthmysql.c      Tue Dec  3 08:32:16 2002
--- dbmail-1.0-authldap/mysql/dbauthmysql.c     Sun Dec 15 13:13:03 2002
***************
*** 48,53 ****
--- 48,54 ----
   */
  int auth_connect()
  {
+ #ifndef DBMAIL_USE_SAME_CONNECTION
    mysql_init(&__auth_conn);
    if (mysql_real_connect (&__auth_conn, _auth_host, _auth_user, _auth_pass, 
_auth_db, 0, NULL, 0) == NULL)
      {
***************
*** 55,68 ****
            mysql_error(&__auth_conn));
        return -1;
      }
! 
    return 0;
  }
  
  
  int auth_disconnect()
  {
    mysql_close(&__auth_conn);
    return 0;
  }
  
--- 56,71 ----
            mysql_error(&__auth_conn));
        return -1;
      }
! #endif
    return 0;
  }
  
  
  int auth_disconnect()
  {
+ #ifndef DBMAIL_USE_SAME_CONNECTION
    mysql_close(&__auth_conn);
+ #endif
    return 0;
  }
  

Reply via email to