Skip to content

Commit bf78309

Browse files
committed
Merge branch 'GangZhuo-ORA-03126'
2 parents f904694 + a565783 commit bf78309

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

modules/db_oracle/asynch.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ sword begin_timelimit(ora_con_t* con, int connect)
189189
}
190190

191191

192-
static sword remap_status(ora_con_t* con, sword status)
192+
static sword remap_status(ora_con_t* con, sword status, sword *errcode)
193193
{
194-
sword code;
194+
sword code = 0;
195195

196196
if ( status == OCI_ERROR
197197
&& OCIErrorGet(con->errhp, 1, NULL, &code,
@@ -200,6 +200,7 @@ static sword remap_status(ora_con_t* con, sword status)
200200
{
201201
status = OCI_STILL_EXECUTING;
202202
}
203+
if (errcode) *errcode = code;
203204
return status;
204205
}
205206

@@ -214,7 +215,7 @@ int wait_timelimit(ora_con_t* con, sword status)
214215
if (!cur_asynch_mode)
215216
return 0;
216217

217-
if (remap_status(con, status) != OCI_STILL_EXECUTING)
218+
if (remap_status(con, status, NULL) != OCI_STILL_EXECUTING)
218219
return 0;
219220

220221
gettimeofday(&cur, NULL);
@@ -230,12 +231,12 @@ int wait_timelimit(ora_con_t* con, sword status)
230231
int done_timelimit(ora_con_t* con, sword status)
231232
{
232233
int ret = 0;
234+
sword code;
233235

234236
if (!cur_asynch_mode)
235237
return 0;
236238

237-
if (remap_status(con, status) == OCI_STILL_EXECUTING) {
238-
sword code;
239+
if (remap_status(con, status, &code) == OCI_STILL_EXECUTING) {
239240

240241
status = OCIBreak(con->svchp, con->errhp);
241242
if (status != OCI_SUCCESS)
@@ -255,6 +256,9 @@ int done_timelimit(ora_con_t* con, sword status)
255256
db_oracle_error(con, status));
256257
db_oracle_disconnect(con);
257258
++ret;
259+
} else if (db_oracle_connection_lost(code)) {
260+
db_oracle_disconnect(con);
261+
cur_asynch_mode = 0;
258262
} else {
259263
status = change_mode(con);
260264
if (status != OCI_SUCCESS) {

modules/db_oracle/dbase.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,17 @@ static const char* db_oracle_errorinfo(ora_con_t* con)
6363
if (OCIErrorGet(con->errhp, 1, NULL, &errcd,
6464
(OraText*)errbuf, sizeof(errbuf),
6565
OCI_HTYPE_ERROR) != OCI_SUCCESS) errbuf[0] = '\0';
66-
else switch (errcd) {
66+
else if (db_oracle_connection_lost(errcd)) {
67+
LM_ERR("connection dropped\n");
68+
db_oracle_disconnect(con);
69+
}
70+
71+
return errbuf;
72+
}
73+
74+
int db_oracle_connection_lost(sword errcode)
75+
{
76+
switch (errcode) {
6777
case 28: /* your session has been killed */
6878
case 30: /* session ID does not exists */
6979
case 31: /* session marked for kill */
@@ -113,13 +123,10 @@ static const char* db_oracle_errorinfo(ora_con_t* con)
113123
case 12561: /* tns unknown error */
114124
case 12608: /* tns send timeount */
115125
case 12609: /* tns receive timeount */
116-
LM_ERR("conneciom dropped\n");
117-
db_oracle_disconnect(con);
118-
default:
119-
break;
126+
return 1;
120127
}
121128

122-
return errbuf;
129+
return 0;
123130
}
124131

125132
const char* db_oracle_error(ora_con_t* con, sword status)

modules/db_oracle/ora_con.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,9 @@ sword db_oracle_reconnect(ora_con_t* con);
9898
*/
9999
const char* db_oracle_error(ora_con_t* con, sword status);
100100

101+
/*
102+
* Does the error code indicate that the connection has been lost
103+
*/
104+
int db_oracle_connection_lost(sword errcode);
105+
101106
#endif /* ORA_CON_H */

0 commit comments

Comments
 (0)