Project

General

Profile

libdbicompat.patch

mckaygerhard, 2019-06-21 07:48

View differences:

lighttpd-1.4.53/configure.ac
365 365
  fi
366 366

  
367 367
  AC_DEFINE([HAVE_DBI], [1], [LibDBI support])
368
  AC_CHECK_LIB(dbi,dbi_initialize_r,AC_DEFINE_UNQUOTED(HAVE_DBI_INITIALIZE_R,[1],[dbi_initialize_r]),[])
368 369
fi
369 370
AM_CONDITIONAL([BUILD_WITH_DBI], [test "$WITH_DBI" != no])
370 371

  
371
-- lighttpd-1.4.53.orig/src/mod_vhostdb_dbi.c
372
++ lighttpd-1.4.53/src/mod_vhostdb_dbi.c
......
23 23

  
24 24
typedef struct {
25 25
    dbi_conn dbconn;
26
#ifdef HAVE_DBI_INITIALIZE_R
26 27
    dbi_inst dbinst;
28
#endif
27 29
    buffer *sqlquery;
28 30
    server *srv;
29 31
    short reconnect_count;
......
64 66
    vhostdb_config *dbconf = (vhostdb_config *)vdata;
65 67
    if (!dbconf) return;
66 68
    dbi_conn_close(dbconf->dbconn);
69
#ifdef HAVE_DBI_INITIALIZE_R
67 70
    dbi_shutdown_r(dbconf->dbinst);
71
#else
72
    dbi_shutdown();
73
#endif
68 74
    free(dbconf);
69 75
}
70 76

  
......
104 110
        && !buffer_is_empty(dbname) && !buffer_is_empty(dbtype)) {
105 111
        /* create/initialise database */
106 112
        vhostdb_config *dbconf;
107
        dbi_inst dbinst = NULL;
108 113
        dbi_conn dbconn;
114
#ifdef HAVE_DBI_INITIALIZE_R
115
        dbi_inst dbinst = NULL;
109 116
        if (dbi_initialize_r(NULL, &dbinst) < 1) {
117
#else
118
        if (dbi_initialize(NULL) < 1) {
119
#endif
110 120
            log_error_write(srv, __FILE__, __LINE__, "s",
111 121
                            "dbi_initialize_r() failed.  "
112 122
                            "Do you have the DBD for this db type installed?");
113 123
            return -1;
114 124
        }
125
#ifdef HAVE_DBI_INITIALIZE_R
115 126
        dbconn = dbi_conn_new_r(dbtype->ptr, dbinst);
127
#else
128
        dbconn = dbi_conn_new(dbtype->ptr);
129
#endif
116 130
        if (NULL == dbconn) {
117 131
            log_error_write(srv, __FILE__, __LINE__, "s",
118 132
                            "dbi_conn_new_r() failed.  "
119 133
                            "Do you have the DBD for this db type installed?");
134
#ifdef HAVE_DBI_INITIALIZE_R
120 135
            dbi_shutdown_r(dbinst);
136
#else
137
            dbi_shutdown();
138
#endif
121 139
            return -1;
122 140
        }
123 141

  
......
139 157
        }
140 158

  
141 159
        dbconf = (vhostdb_config *)calloc(1, sizeof(*dbconf));
160
#ifdef HAVE_DBI_INITIALIZE_R
142 161
        dbconf->dbinst = dbinst;
162
#endif
143 163
        dbconf->dbconn = dbconn;
144 164
        dbconf->sqlquery = sqlquery;
145 165
        dbconf->srv = srv;