… | |
… | |
150 | enum { |
150 | enum { |
151 | REQ_QUIT, |
151 | REQ_QUIT, |
152 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
152 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
153 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
153 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
154 | REQ_ENV_LOG_ARCHIVE, |
154 | REQ_ENV_LOG_ARCHIVE, |
155 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_UPGRADE, |
155 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_VERIFY, REQ_DB_UPGRADE, |
156 | REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
156 | REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
157 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
157 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
158 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
158 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
159 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
159 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
160 | }; |
160 | }; |
… | |
… | |
547 | if (sock [0] != INVALID_SOCKET) closesocket (sock [0]); |
547 | if (sock [0] != INVALID_SOCKET) closesocket (sock [0]); |
548 | if (sock [1] != INVALID_SOCKET) closesocket (sock [1]); |
548 | if (sock [1] != INVALID_SOCKET) closesocket (sock [1]); |
549 | |
549 | |
550 | return -1; |
550 | return -1; |
551 | } |
551 | } |
|
|
552 | |
|
|
553 | #define pipe(filedes) ev_pipe(filedes) |
552 | #endif |
554 | #endif |
553 | |
555 | |
554 | static void |
556 | static void |
555 | create_respipe (void) |
557 | create_respipe (void) |
556 | { |
558 | { |
… | |
… | |
560 | int old_readfd = respipe [0]; |
562 | int old_readfd = respipe [0]; |
561 | |
563 | |
562 | if (respipe [1] >= 0) |
564 | if (respipe [1] >= 0) |
563 | respipe_close (TO_SOCKET (respipe [1])); |
565 | respipe_close (TO_SOCKET (respipe [1])); |
564 | |
566 | |
565 | #ifdef _WIN32 |
|
|
566 | if (ev_pipe (respipe)) |
|
|
567 | #else |
|
|
568 | if (pipe (respipe)) |
567 | if (pipe (respipe)) |
569 | #endif |
|
|
570 | croak ("unable to initialize result pipe"); |
568 | croak ("unable to initialize result pipe"); |
571 | |
569 | |
572 | if (old_readfd >= 0) |
570 | if (old_readfd >= 0) |
573 | { |
571 | { |
574 | if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0) |
572 | if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0) |
… | |
… | |
883 | break; |
881 | break; |
884 | #endif |
882 | #endif |
885 | |
883 | |
886 | case REQ_DB_SYNC: |
884 | case REQ_DB_SYNC: |
887 | req->result = req->db->sync (req->db, req->uint1); |
885 | req->result = req->db->sync (req->db, req->uint1); |
|
|
886 | break; |
|
|
887 | |
|
|
888 | case REQ_DB_VERIFY: |
|
|
889 | req->result = req->db->verify (req->db, req->buf1, req->buf2, 0, req->uint1); |
888 | break; |
890 | break; |
889 | |
891 | |
890 | case REQ_DB_UPGRADE: |
892 | case REQ_DB_UPGRADE: |
891 | req->result = req->db->upgrade (req->db, req->buf1, req->uint1); |
893 | req->result = req->db->upgrade (req->db, req->buf1, req->uint1); |
892 | break; |
894 | break; |
… | |
… | |
1436 | const_iv (REP_UNAVAIL) |
1438 | const_iv (REP_UNAVAIL) |
1437 | const_iv (RUNRECOVERY) |
1439 | const_iv (RUNRECOVERY) |
1438 | const_iv (SECONDARY_BAD) |
1440 | const_iv (SECONDARY_BAD) |
1439 | const_iv (VERIFY_BAD) |
1441 | const_iv (VERIFY_BAD) |
1440 | |
1442 | |
|
|
1443 | const_iv (SALVAGE) |
|
|
1444 | const_iv (AGGRESSIVE) |
|
|
1445 | const_iv (PRINTABLE) |
|
|
1446 | const_iv (NOORDERCHK) |
|
|
1447 | const_iv (ORDERCHKONLY) |
|
|
1448 | |
1441 | const_iv (ARCH_ABS) |
1449 | const_iv (ARCH_ABS) |
1442 | const_iv (ARCH_DATA) |
1450 | const_iv (ARCH_DATA) |
1443 | const_iv (ARCH_LOG) |
1451 | const_iv (ARCH_LOG) |
1444 | const_iv (ARCH_REMOVE) |
1452 | const_iv (ARCH_REMOVE) |
1445 | |
1453 | |
… | |
… | |
1890 | req->uint1 = flags; |
1898 | req->uint1 = flags; |
1891 | REQ_SEND; |
1899 | REQ_SEND; |
1892 | } |
1900 | } |
1893 | |
1901 | |
1894 | void |
1902 | void |
|
|
1903 | db_verify (DB *db, bdb_filename file, bdb_filename database = 0, SV *dummy = 0, U32 flags = 0, SV *callback = 0) |
|
|
1904 | PREINIT: |
|
|
1905 | CALLBACK |
|
|
1906 | CODE: |
|
|
1907 | { |
|
|
1908 | dREQ (REQ_DB_VERIFY, 1); |
|
|
1909 | ptr_nuke (ST (0)); /* verify destroys the database handle, hopefully it is freed as well */ |
|
|
1910 | req->db = db; |
|
|
1911 | req->buf1 = strdup (file); |
|
|
1912 | req->buf2 = strdup_ornull (database); |
|
|
1913 | req->uint1 = flags; |
|
|
1914 | REQ_SEND; |
|
|
1915 | } |
|
|
1916 | |
|
|
1917 | void |
1895 | db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) |
1918 | db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) |
1896 | PREINIT: |
1919 | PREINIT: |
1897 | CALLBACK |
1920 | CALLBACK |
1898 | CODE: |
1921 | CODE: |
1899 | { |
1922 | { |
1900 | dREQ (REQ_DB_SYNC, 1); |
1923 | dREQ (REQ_DB_UPGRADE, 1); |
1901 | req->db = db; |
1924 | req->db = db; |
1902 | req->buf1 = strdup (file); |
1925 | req->buf1 = strdup (file); |
1903 | req->uint1 = flags; |
1926 | req->uint1 = flags; |
1904 | REQ_SEND; |
1927 | REQ_SEND; |
1905 | } |
1928 | } |