~ubuntu-branches/ubuntu/raring/firebird2.5/raring-proposed

« back to all changes in this revision

Viewing changes to src/burp/burp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2011-09-24 14:12:19 UTC
  • mfrom: (15.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110924141219-pkxk7486f3d8ut9f
Tags: 2.5.1.26349-0~rc1.ds4-5
* Medium urgency for fixing a serious bug in testing

* Import a patch from upstream SVN fixing problems in poll() usage when
  process receives signals like SIGALRM.
  Closes: #642555 -- segfault in the remote interface when using alarm() in
  the client program

Show diffs side-by-side

added added

removed removed

Lines of Context:
291
291
                if (isc_service_attach(status, 0, service.c_str(), &svc_handle,
292
292
                                                           spb.getBufferLength(), reinterpret_cast<const char*>(spb.getBuffer())))
293
293
                {
294
 
                        BURP_print_status(status);
 
294
                        BURP_print_status(true, status);
295
295
                        BURP_print(true, 83);
296
296
                        // msg 83 Exiting before completion due to errors
297
297
                        return FINI_ERROR;
314
314
 
315
315
                if (isc_service_start(status, &svc_handle, NULL, thdlen, thd))
316
316
                {
317
 
                        BURP_print_status(status);
 
317
                        BURP_print_status(true, status);
318
318
                        isc_service_detach(status, &svc_handle);
319
319
                        BURP_print(true, 83);   // msg 83 Exiting before completion due to errors
320
320
                        return FINI_ERROR;
328
328
                                                                  sizeof(sendbuf), sendbuf,
329
329
                                                                  sizeof(respbuf), respbuf))
330
330
                        {
331
 
                                BURP_print_status(status);
 
331
                                BURP_print_status(true, status);
332
332
                                isc_service_detach(status, &svc_handle);
333
333
                                BURP_print(true, 83);   // msg 83 Exiting before completion due to errors
334
334
                                return FINI_ERROR;
362
362
        catch (const Firebird::Exception& e)
363
363
        {
364
364
                e.stuff_exception(status);
365
 
                BURP_print_status(status);
 
365
                BURP_print_status(true, status);
366
366
                if (svc_handle)
367
367
                {
368
368
                        isc_service_detach(status, &svc_handle);
1115
1115
                // Non-burp exception was caught
1116
1116
                tdgbl->burp_throw = false;
1117
1117
                e.stuff_exception(tdgbl->status_vector);
1118
 
                BURP_print_status(tdgbl->status_vector, true);
 
1118
                BURP_print_status(true, tdgbl->status_vector);
1119
1119
                BURP_print(true, 83);   // msg 83 Exiting before completion due to errors
1120
1120
                exit_code = FINI_ERROR;
1121
1121
        }
1138
1138
                close_out_transaction(action, &tdgbl->global_trans);
1139
1139
                if (isc_detach_database(tdgbl->status_vector, &tdgbl->db_handle))
1140
1140
                {
1141
 
                        BURP_print_status(tdgbl->status_vector, true);
 
1141
                        BURP_print_status(true, tdgbl->status_vector);
1142
1142
                }
1143
1143
        }
1144
1144
 
1250
1250
 *
1251
1251
 **************************************/
1252
1252
 
1253
 
        BURP_print_status(status_vector, true);
 
1253
        BURP_print_status(true, status_vector);
1254
1254
        BURP_error(errcode, true, arg);
1255
1255
}
1256
1256
 
1382
1382
}
1383
1383
 
1384
1384
 
1385
 
void BURP_print_status(const ISC_STATUS* status_vector, bool flagStuff)
 
1385
void BURP_print_status(bool err, const ISC_STATUS* status_vector)
1386
1386
{
1387
1387
/**************************************
1388
1388
 *
1398
1398
        if (status_vector) {
1399
1399
                const ISC_STATUS* vector = status_vector;
1400
1400
 
1401
 
                if (flagStuff) {
 
1401
                if (err) {
1402
1402
                        BurpGlobals* tdgbl = BurpGlobals::getSpecific();
1403
1403
                        tdgbl->uSvc->setServiceStatus(vector);
1404
1404
                        tdgbl->uSvc->started();
1410
1410
 
1411
1411
        SCHAR s[1024];
1412
1412
                if (fb_interpret(s, sizeof(s), &vector)) {
1413
 
                        BURP_msg_partial(true, 256); // msg 256: gbak: ERROR:
1414
 
                        burp_output(true, "%s\n", s);
 
1413
                        BURP_msg_partial(err, 256); // msg 256: gbak: ERROR:
 
1414
                        burp_output(err, "%s\n", s);
1415
1415
                        while (fb_interpret(s, sizeof(s), &vector)) {
1416
 
                                BURP_msg_partial(true, 256); // msg 256: gbak: ERROR:
1417
 
                                burp_output(true, "    %s\n", s);
 
1416
                                BURP_msg_partial(err, 256); // msg 256: gbak: ERROR:
 
1417
                                burp_output(err, "    %s\n", s);
1418
1418
                        }
1419
1419
                }
1420
1420
        }
1529
1529
                                // we can detach from the database.
1530
1530
                                isc_rollback_transaction(status_vector, handle);
1531
1531
                                if (status_vector[1])
1532
 
                                        BURP_print_status(status_vector);
 
1532
                                        BURP_print_status(false, status_vector);
1533
1533
                        }
1534
1534
                }
1535
1535
                else
1538
1538
                        // by never writing data during a backup, but let's double
1539
1539
                        // ensure it by doing a rollback
1540
1540
                        if (isc_rollback_transaction(status_vector, handle))
1541
 
                                BURP_print_status(status_vector);
 
1541
                                BURP_print_status(false, status_vector);
1542
1542
                }
1543
1543
        }
1544
1544
}
1610
1610
                                // msg 13 REPLACE specified, but the first file %s is a database
1611
1611
                                BURP_error(13, true, file1);
1612
1612
                                if (isc_detach_database(status_vector, &tdgbl->db_handle)) {
1613
 
                                        BURP_print_status(status_vector, true);
 
1613
                                        BURP_print_status(true, status_vector);
1614
1614
                                }
1615
1615
                                return QUIT;
1616
1616
                        }
1626
1626
                else if (sw_replace == IN_SW_BURP_B ||
1627
1627
                        (status_vector[1] != isc_io_error && status_vector[1] != isc_bad_db_format))
1628
1628
                {
1629
 
                        BURP_print_status(status_vector, true);
 
1629
                        BURP_print_status(true, status_vector);
1630
1630
                        return QUIT;
1631
1631
                }
1632
1632
        }
1746
1746
                {
1747
1747
                        if (isc_detach_database(status_vector, &tdgbl->db_handle))
1748
1748
                        {
1749
 
                                BURP_print_status(status_vector);
 
1749
                                BURP_print_status(false, status_vector);
1750
1750
                        }
1751
1751
                }
1752
1752
 
1926
1926
        {
1927
1927
                if (sw_replace == IN_SW_BURP_C) {
1928
1928
                        if (isc_detach_database(status_vector, &tdgbl->db_handle)) {
1929
 
                                BURP_print_status(status_vector, true);
 
1929
                                BURP_print_status(true, status_vector);
1930
1930
                        }
1931
1931
                        BURP_error(14, true, *file2);
1932
1932
                        // msg 14 database %s already exists.  To replace it, use the -R switch
1937
1937
                                Firebird::makePermanentVector(status_vector);
1938
1938
                                ISC_STATUS_ARRAY status_vector2;
1939
1939
                                if (isc_detach_database(status_vector2, &tdgbl->db_handle)) {
1940
 
                                        BURP_print_status(status_vector2);
 
1940
                                        BURP_print_status(false, status_vector2);
1941
1941
                                }
1942
1942
 
1943
1943
                                // Complain only if the drop database entrypoint is available.
2134
2134
        file->fil_length = size;
2135
2135
        return size;
2136
2136
}
 
2137
 
 
2138
 
 
2139
#ifndef WIN_NT
 
2140
void close_platf(DESC file)
 
2141
{
 
2142
/**********************************************
 
2143
 *
 
2144
 *      c l o s e _ p l a t f
 
2145
 *
 
2146
 **********************************************
 
2147
 *
 
2148
 * Functional description
 
2149
 *      Truncate and close file - posix version
 
2150
 *
 
2151
 **********************************************/
 
2152
        if (sizeof(off_t) > 4)          // 64 bit or b4-bit IO in 32 bit OS
 
2153
        {
 
2154
#ifndef O_ACCMODE
 
2155
// Suppose compatibility with KR where 0, 1, 2 were documented for RO, WO and RW in open() still exists
 
2156
#define O_ACCMODE 3
 
2157
#endif
 
2158
                off_t fileSize = lseek(file, 0, SEEK_CUR);
 
2159
                if (fileSize != (off_t)(-1))
 
2160
                {
 
2161
                        ftruncate(file, fileSize);
 
2162
                }
 
2163
        }
 
2164
        close(file);
 
2165
}
 
2166
#endif // WIN_NT