… | |
… | |
18 | |
18 | |
19 | #include <stddef.h> |
19 | #include <stddef.h> |
20 | #include <stdlib.h> |
20 | #include <stdlib.h> |
21 | #include <errno.h> |
21 | #include <errno.h> |
22 | #include <sys/time.h> |
22 | #include <sys/time.h> |
23 | #include <sys/select.h> |
|
|
24 | #include <sys/types.h> |
23 | #include <sys/types.h> |
25 | #include <sys/stat.h> |
|
|
26 | #include <limits.h> |
24 | #include <limits.h> |
27 | #include <unistd.h> |
25 | #include <unistd.h> |
28 | #include <fcntl.h> |
26 | #include <fcntl.h> |
29 | #include <signal.h> |
27 | |
30 | #include <sched.h> |
28 | #include <db.h> |
31 | |
29 | |
32 | /* number of seconds after which idle threads exit */ |
30 | /* number of seconds after which idle threads exit */ |
33 | #define IDLE_TIMEOUT 10 |
31 | #define IDLE_TIMEOUT 10 |
34 | |
32 | |
35 | /* wether word reads are potentially non-atomic. |
33 | /* wether word reads are potentially non-atomic. |
… | |
… | |
43 | # define WORDACCESS_UNSAFE 1 |
41 | # define WORDACCESS_UNSAFE 1 |
44 | # endif |
42 | # endif |
45 | #endif |
43 | #endif |
46 | |
44 | |
47 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
45 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
|
|
46 | typedef char *octetstring; |
|
|
47 | |
|
|
48 | static SV *prepare_cb; |
|
|
49 | |
|
|
50 | static inline char * |
|
|
51 | strdup_ornull (const char *s) |
|
|
52 | { |
|
|
53 | return s ? strdup (s) : 0; |
|
|
54 | } |
48 | |
55 | |
49 | enum { |
56 | enum { |
50 | REQ_QUIT, |
57 | REQ_QUIT, |
|
|
58 | REQ_ENV_OPEN, REQ_ENV_CLOSE, |
|
|
59 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_PUT, |
51 | }; |
60 | }; |
52 | |
61 | |
53 | #define AIO_CB \ |
|
|
54 | struct aio_cb *volatile next; \ |
|
|
55 | SV *callback; \ |
|
|
56 | int type, pri |
|
|
57 | |
|
|
58 | typedef struct aio_cb |
62 | typedef struct aio_cb |
59 | { |
63 | { |
60 | AIO_CB; |
64 | struct aio_cb *volatile next; |
|
|
65 | SV *callback; |
|
|
66 | int type, pri, result; |
|
|
67 | |
|
|
68 | DB_ENV *env; |
|
|
69 | DB *db; |
|
|
70 | DB_TXN *txn; |
|
|
71 | DBC *cursor; |
|
|
72 | int int1, int2; |
|
|
73 | U32 uint1, uint2; |
|
|
74 | char *buf1, *buf2; |
|
|
75 | |
|
|
76 | DBT dbt1, dbt2, dbt3; |
61 | } aio_cb; |
77 | } aio_cb; |
62 | |
78 | |
63 | typedef aio_cb *aio_req; |
79 | typedef aio_cb *aio_req; |
64 | |
80 | |
65 | enum { |
81 | enum { |
… | |
… | |
230 | |
246 | |
231 | abort (); |
247 | abort (); |
232 | } |
248 | } |
233 | |
249 | |
234 | static int poll_cb (); |
250 | static int poll_cb (); |
235 | static int req_invoke (aio_req req); |
|
|
236 | static void req_free (aio_req req); |
251 | static void req_free (aio_req req); |
237 | static void req_cancel (aio_req req); |
252 | static void req_cancel (aio_req req); |
238 | |
253 | |
239 | static int req_invoke (aio_req req) |
254 | static int req_invoke (aio_req req) |
240 | { |
255 | { |
… | |
… | |
249 | |
264 | |
250 | switch (req->type) |
265 | switch (req->type) |
251 | { |
266 | { |
252 | } |
267 | } |
253 | |
268 | |
|
|
269 | errno = req->result; |
|
|
270 | |
254 | PUTBACK; |
271 | PUTBACK; |
255 | call_sv (req->callback, G_VOID | G_EVAL); |
272 | call_sv (req->callback, G_VOID | G_EVAL); |
256 | SPAGAIN; |
273 | SPAGAIN; |
257 | |
274 | |
258 | FREETMPS; |
275 | FREETMPS; |
… | |
… | |
262 | return !SvTRUE (ERRSV); |
279 | return !SvTRUE (ERRSV); |
263 | } |
280 | } |
264 | |
281 | |
265 | static void req_free (aio_req req) |
282 | static void req_free (aio_req req) |
266 | { |
283 | { |
|
|
284 | free (req->buf1); |
|
|
285 | free (req->buf2); |
267 | Safefree (req); |
286 | Safefree (req); |
268 | } |
287 | } |
269 | |
288 | |
270 | static void *aio_proc(void *arg); |
289 | static void *aio_proc (void *arg); |
271 | |
290 | |
272 | static void start_thread (void) |
291 | static void start_thread (void) |
273 | { |
292 | { |
274 | sigset_t fullsigset, oldsigset; |
293 | sigset_t fullsigset, oldsigset; |
275 | pthread_attr_t attr; |
294 | pthread_attr_t attr; |
… | |
… | |
317 | start_thread (); |
336 | start_thread (); |
318 | } |
337 | } |
319 | |
338 | |
320 | static void req_send (aio_req req) |
339 | static void req_send (aio_req req) |
321 | { |
340 | { |
|
|
341 | SV *wait_callback = 0; |
|
|
342 | |
|
|
343 | // synthesize callback if none given |
|
|
344 | if (!SvOK (req->callback)) |
|
|
345 | { |
|
|
346 | dSP; |
|
|
347 | PUSHMARK (SP); |
|
|
348 | PUTBACK; |
|
|
349 | int count = call_sv (prepare_cb, G_ARRAY); |
|
|
350 | SPAGAIN; |
|
|
351 | |
|
|
352 | if (count != 2) |
|
|
353 | croak ("prepare callback must return exactly two values\n"); |
|
|
354 | |
|
|
355 | wait_callback = SvREFCNT_inc (POPs); |
|
|
356 | SvREFCNT_dec (req->callback); |
|
|
357 | req->callback = SvREFCNT_inc (POPs); |
|
|
358 | } |
|
|
359 | |
322 | ++nreqs; |
360 | ++nreqs; |
323 | |
361 | |
324 | LOCK (reqlock); |
362 | LOCK (reqlock); |
325 | ++nready; |
363 | ++nready; |
326 | reqq_push (&req_queue, req); |
364 | reqq_push (&req_queue, req); |
327 | pthread_cond_signal (&reqwait); |
365 | pthread_cond_signal (&reqwait); |
328 | UNLOCK (reqlock); |
366 | UNLOCK (reqlock); |
329 | |
367 | |
330 | maybe_start_thread (); |
368 | maybe_start_thread (); |
|
|
369 | |
|
|
370 | if (wait_callback) |
|
|
371 | { |
|
|
372 | dSP; |
|
|
373 | PUSHMARK (SP); |
|
|
374 | PUTBACK; |
|
|
375 | call_sv (wait_callback, G_DISCARD); |
|
|
376 | SvREFCNT_dec (wait_callback); |
|
|
377 | } |
331 | } |
378 | } |
332 | |
379 | |
333 | static void end_thread (void) |
380 | static void end_thread (void) |
334 | { |
381 | { |
335 | aio_req req; |
382 | aio_req req; |
… | |
… | |
530 | |
577 | |
531 | --nready; |
578 | --nready; |
532 | |
579 | |
533 | UNLOCK (reqlock); |
580 | UNLOCK (reqlock); |
534 | |
581 | |
535 | errno = 0; /* strictly unnecessary */ |
|
|
536 | |
|
|
537 | switch (req->type) |
582 | switch (req->type) |
538 | { |
583 | { |
539 | case REQ_QUIT: |
584 | case REQ_QUIT: |
540 | goto quit; |
585 | goto quit; |
541 | |
586 | |
|
|
587 | case REQ_ENV_OPEN: |
|
|
588 | req->result = req->env->open (req->env, req->buf1, req->uint1, req->int1); |
|
|
589 | break; |
|
|
590 | |
|
|
591 | case REQ_ENV_CLOSE: |
|
|
592 | req->result = req->env->close (req->env, req->uint1); |
|
|
593 | break; |
|
|
594 | |
|
|
595 | case REQ_DB_OPEN: |
|
|
596 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
|
|
597 | break; |
|
|
598 | |
|
|
599 | case REQ_DB_CLOSE: |
|
|
600 | req->result = req->db->close (req->db, req->uint1); |
|
|
601 | break; |
|
|
602 | |
|
|
603 | case REQ_DB_COMPACT: |
|
|
604 | req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); |
|
|
605 | break; |
|
|
606 | |
|
|
607 | case REQ_DB_SYNC: |
|
|
608 | req->result = req->db->sync (req->db, req->uint1); |
|
|
609 | break; |
|
|
610 | |
|
|
611 | case REQ_DB_PUT: |
|
|
612 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
|
|
613 | break; |
|
|
614 | |
542 | default: |
615 | default: |
543 | //req->result = ENOSYS; |
616 | req->result = ENOSYS; |
544 | break; |
617 | break; |
545 | } |
618 | } |
546 | |
|
|
547 | //req->errorno = errno; |
|
|
548 | |
619 | |
549 | LOCK (reslock); |
620 | LOCK (reslock); |
550 | |
621 | |
551 | ++npending; |
622 | ++npending; |
552 | |
623 | |
… | |
… | |
616 | create_pipe (); |
687 | create_pipe (); |
617 | |
688 | |
618 | atfork_parent (); |
689 | atfork_parent (); |
619 | } |
690 | } |
620 | |
691 | |
621 | #define dREQ \ |
692 | #define dREQ(reqtype) \ |
622 | aio_req req; \ |
693 | aio_req req; \ |
623 | int req_pri = next_pri; \ |
694 | int req_pri = next_pri; \ |
624 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
695 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
625 | \ |
696 | \ |
626 | if (SvOK (callback) && !SvROK (callback)) \ |
697 | if (SvOK (callback) && !SvROK (callback)) \ |
627 | croak ("callback must be undef or of reference type"); \ |
698 | croak ("callback must be undef or of reference type"); \ |
628 | \ |
699 | \ |
629 | Newz (0, req, 1, aio_cb); \ |
700 | Newz (0, req, 1, aio_cb); \ |
630 | if (!req) \ |
701 | if (!req) \ |
631 | croak ("out of memory during aio_req allocation"); \ |
702 | croak ("out of memory during aio_req allocation"); \ |
632 | \ |
703 | \ |
633 | req->callback = newSVsv (callback); \ |
704 | req->callback = newSVsv (callback); \ |
|
|
705 | req->type = (reqtype); \ |
634 | req->pri = req_pri |
706 | req->pri = req_pri |
635 | |
707 | |
636 | #define REQ_SEND \ |
708 | #define REQ_SEND \ |
637 | req_send (req); \ |
709 | req_send (req) |
638 | \ |
710 | |
639 | if (GIMME_V != G_VOID) \ |
711 | #define SvPTR(var, arg, type, class) \ |
640 | XPUSHs (req_sv (req, AIO_REQ_KLASS)); |
712 | if (!SvOK (arg)) \ |
|
|
713 | (var) = 0; \ |
|
|
714 | else if (sv_derived_from ((arg), # class)) \ |
|
|
715 | { \ |
|
|
716 | IV tmp = SvIV ((SV*) SvRV (arg)); \ |
|
|
717 | (var) = INT2PTR (type, tmp); \ |
|
|
718 | } \ |
|
|
719 | else \ |
|
|
720 | Perl_croak (# var " is not of type " # class) |
|
|
721 | |
|
|
722 | inline void |
|
|
723 | set_dbt (DBT *dbt, SV *sv) |
|
|
724 | { |
|
|
725 | STRLEN len; |
|
|
726 | char *data = SvPVbyte (sv, len); |
|
|
727 | |
|
|
728 | dbt->data = malloc (len); |
|
|
729 | memcpy (dbt->data, data, len); |
|
|
730 | dbt->size = len; |
|
|
731 | } |
641 | |
732 | |
642 | MODULE = BDB::AIO PACKAGE = BDB::AIO |
733 | MODULE = BDB PACKAGE = BDB |
643 | |
734 | |
644 | PROTOTYPES: ENABLE |
735 | PROTOTYPES: ENABLE |
645 | |
736 | |
646 | BOOT: |
737 | BOOT: |
647 | { |
738 | { |
648 | HV *stash = gv_stashpv ("BDB::AIO", 1); |
739 | HV *stash = gv_stashpv ("BDB", 1); |
|
|
740 | |
|
|
741 | static const struct { |
|
|
742 | const char *name; |
|
|
743 | IV iv; |
|
|
744 | } *civ, const_iv[] = { |
|
|
745 | #define const_iv(name) { # name, (IV)DB_ ## name }, |
|
|
746 | const_iv (RPCCLIENT) |
|
|
747 | const_iv (INIT_CDB) |
|
|
748 | const_iv (INIT_LOCK) |
|
|
749 | const_iv (INIT_LOG) |
|
|
750 | const_iv (INIT_MPOOL) |
|
|
751 | const_iv (INIT_REP) |
|
|
752 | const_iv (INIT_TXN) |
|
|
753 | const_iv (RECOVER) |
|
|
754 | const_iv (INIT_TXN) |
|
|
755 | const_iv (RECOVER_FATAL) |
|
|
756 | const_iv (CREATE) |
|
|
757 | const_iv (USE_ENVIRON) |
|
|
758 | const_iv (USE_ENVIRON_ROOT) |
|
|
759 | const_iv (LOCKDOWN) |
|
|
760 | const_iv (PRIVATE) |
|
|
761 | const_iv (REGISTER) |
|
|
762 | const_iv (SYSTEM_MEM) |
|
|
763 | const_iv (AUTO_COMMIT) |
|
|
764 | const_iv (CDB_ALLDB) |
|
|
765 | const_iv (DIRECT_DB) |
|
|
766 | const_iv (DIRECT_LOG) |
|
|
767 | const_iv (DSYNC_DB) |
|
|
768 | const_iv (DSYNC_LOG) |
|
|
769 | const_iv (LOG_AUTOREMOVE) |
|
|
770 | const_iv (LOG_INMEMORY) |
|
|
771 | const_iv (NOLOCKING) |
|
|
772 | const_iv (MULTIVERSION) |
|
|
773 | const_iv (NOMMAP) |
|
|
774 | const_iv (NOPANIC) |
|
|
775 | const_iv (OVERWRITE) |
|
|
776 | const_iv (PANIC_ENVIRONMENT) |
|
|
777 | const_iv (REGION_INIT) |
|
|
778 | const_iv (TIME_NOTGRANTED) |
|
|
779 | const_iv (TXN_NOSYNC) |
|
|
780 | const_iv (TXN_SNAPSHOT) |
|
|
781 | const_iv (TXN_WRITE_NOSYNC) |
|
|
782 | const_iv (YIELDCPU) |
|
|
783 | const_iv (ENCRYPT_AES) |
|
|
784 | const_iv (XA_CREATE) |
|
|
785 | const_iv (BTREE) |
|
|
786 | const_iv (HASH) |
|
|
787 | const_iv (QUEUE) |
|
|
788 | const_iv (RECNO) |
|
|
789 | const_iv (UNKNOWN) |
|
|
790 | const_iv (EXCL) |
|
|
791 | const_iv (READ_COMMITTED) |
|
|
792 | const_iv (READ_UNCOMMITTED) |
|
|
793 | const_iv (TRUNCATE) |
|
|
794 | const_iv (NOSYNC) |
|
|
795 | const_iv (CHKSUM) |
|
|
796 | const_iv (ENCRYPT) |
|
|
797 | const_iv (TXN_NOT_DURABLE) |
|
|
798 | const_iv (DUP) |
|
|
799 | const_iv (DUPSORT) |
|
|
800 | const_iv (RECNUM) |
|
|
801 | const_iv (RENUMBER) |
|
|
802 | const_iv (REVSPLITOFF) |
|
|
803 | const_iv (INORDER) |
|
|
804 | const_iv (CONSUME) |
|
|
805 | const_iv (CONSUME_WAIT) |
|
|
806 | const_iv (SNAPSHOT) |
|
|
807 | const_iv (JOIN_ITEM) |
|
|
808 | const_iv (RMW) |
|
|
809 | |
|
|
810 | const_iv (NOTFOUND) |
|
|
811 | const_iv (KEYEMPTY) |
|
|
812 | const_iv (LOCK_DEADLOCK) |
|
|
813 | const_iv (LOCK_NOTGRANTED) |
|
|
814 | const_iv (RUNRECOVERY) |
|
|
815 | const_iv (OLD_VERSION) |
|
|
816 | const_iv (REP_HANDLE_DEAD) |
|
|
817 | const_iv (REP_LOCKOUT) |
|
|
818 | |
|
|
819 | const_iv (FREE_SPACE) |
|
|
820 | const_iv (FREELIST_ONLY) |
|
|
821 | |
|
|
822 | const_iv (APPEND) |
|
|
823 | const_iv (NODUPDATA) |
|
|
824 | const_iv (NOOVERWRITE) |
|
|
825 | |
|
|
826 | const_iv (TXN_NOWAIT) |
|
|
827 | const_iv (TXN_SNAPSHOT) |
|
|
828 | const_iv (TXN_SYNC) |
|
|
829 | |
|
|
830 | const_iv (SET_LOCK_TIMEOUT) |
|
|
831 | const_iv (SET_TXN_TIMEOUT) |
|
|
832 | }; |
|
|
833 | |
|
|
834 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
|
|
835 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
649 | |
836 | |
650 | create_pipe (); |
837 | create_pipe (); |
651 | pthread_atfork (atfork_prepare, atfork_parent, atfork_child); |
838 | pthread_atfork (atfork_prepare, atfork_parent, atfork_child); |
652 | } |
839 | } |
653 | |
840 | |
… | |
… | |
685 | max_outstanding = maxreqs; |
872 | max_outstanding = maxreqs; |
686 | OUTPUT: |
873 | OUTPUT: |
687 | RETVAL |
874 | RETVAL |
688 | |
875 | |
689 | int |
876 | int |
690 | bdbreq_pri (int pri = 0) |
877 | dbreq_pri (int pri = 0) |
691 | PROTOTYPE: ;$ |
878 | PROTOTYPE: ;$ |
692 | CODE: |
879 | CODE: |
693 | RETVAL = next_pri - PRI_BIAS; |
880 | RETVAL = next_pri - PRI_BIAS; |
694 | if (items > 0) |
881 | if (items > 0) |
695 | { |
882 | { |
… | |
… | |
699 | } |
886 | } |
700 | OUTPUT: |
887 | OUTPUT: |
701 | RETVAL |
888 | RETVAL |
702 | |
889 | |
703 | void |
890 | void |
704 | bdbreq_nice (int nice = 0) |
891 | dbreq_nice (int nice = 0) |
705 | CODE: |
892 | CODE: |
706 | nice = next_pri - nice; |
893 | nice = next_pri - nice; |
707 | if (nice < PRI_MIN) nice = PRI_MIN; |
894 | if (nice < PRI_MIN) nice = PRI_MIN; |
708 | if (nice > PRI_MAX) nice = PRI_MAX; |
895 | if (nice > PRI_MAX) nice = PRI_MAX; |
709 | next_pri = nice + PRI_BIAS; |
896 | next_pri = nice + PRI_BIAS; |
… | |
… | |
717 | poll_wait (); |
904 | poll_wait (); |
718 | poll_cb (); |
905 | poll_cb (); |
719 | } |
906 | } |
720 | |
907 | |
721 | int |
908 | int |
722 | poll() |
909 | poll () |
723 | PROTOTYPE: |
910 | PROTOTYPE: |
724 | CODE: |
911 | CODE: |
725 | poll_wait (); |
912 | poll_wait (); |
726 | RETVAL = poll_cb (); |
913 | RETVAL = poll_cb (); |
727 | OUTPUT: |
914 | OUTPUT: |
728 | RETVAL |
915 | RETVAL |
729 | |
916 | |
730 | int |
917 | int |
731 | poll_fileno() |
918 | poll_fileno () |
732 | PROTOTYPE: |
919 | PROTOTYPE: |
733 | CODE: |
920 | CODE: |
734 | RETVAL = respipe [0]; |
921 | RETVAL = respipe [0]; |
735 | OUTPUT: |
922 | OUTPUT: |
736 | RETVAL |
923 | RETVAL |
737 | |
924 | |
738 | int |
925 | int |
739 | poll_cb(...) |
926 | poll_cb (...) |
740 | PROTOTYPE: |
927 | PROTOTYPE: |
741 | CODE: |
928 | CODE: |
742 | RETVAL = poll_cb (); |
929 | RETVAL = poll_cb (); |
743 | OUTPUT: |
930 | OUTPUT: |
744 | RETVAL |
931 | RETVAL |
745 | |
932 | |
746 | void |
933 | void |
747 | poll_wait() |
934 | poll_wait () |
748 | PROTOTYPE: |
935 | PROTOTYPE: |
749 | CODE: |
936 | CODE: |
750 | poll_wait (); |
937 | poll_wait (); |
751 | |
938 | |
752 | int |
939 | int |
753 | nreqs() |
940 | nreqs () |
754 | PROTOTYPE: |
941 | PROTOTYPE: |
755 | CODE: |
942 | CODE: |
756 | RETVAL = nreqs; |
943 | RETVAL = nreqs; |
757 | OUTPUT: |
944 | OUTPUT: |
758 | RETVAL |
945 | RETVAL |
759 | |
946 | |
760 | int |
947 | int |
761 | nready() |
948 | nready () |
762 | PROTOTYPE: |
949 | PROTOTYPE: |
763 | CODE: |
950 | CODE: |
764 | RETVAL = get_nready (); |
951 | RETVAL = get_nready (); |
765 | OUTPUT: |
952 | OUTPUT: |
766 | RETVAL |
953 | RETVAL |
767 | |
954 | |
768 | int |
955 | int |
769 | npending() |
956 | npending () |
770 | PROTOTYPE: |
957 | PROTOTYPE: |
771 | CODE: |
958 | CODE: |
772 | RETVAL = get_npending (); |
959 | RETVAL = get_npending (); |
773 | OUTPUT: |
960 | OUTPUT: |
774 | RETVAL |
961 | RETVAL |
775 | |
962 | |
776 | int |
963 | int |
777 | nthreads() |
964 | nthreads () |
778 | PROTOTYPE: |
965 | PROTOTYPE: |
779 | CODE: |
966 | CODE: |
780 | if (WORDACCESS_UNSAFE) LOCK (wrklock); |
967 | if (WORDACCESS_UNSAFE) LOCK (wrklock); |
781 | RETVAL = started; |
968 | RETVAL = started; |
782 | if (WORDACCESS_UNSAFE) UNLOCK (wrklock); |
969 | if (WORDACCESS_UNSAFE) UNLOCK (wrklock); |
783 | OUTPUT: |
970 | OUTPUT: |
784 | RETVAL |
971 | RETVAL |
785 | |
972 | |
|
|
973 | void |
|
|
974 | set_sync_prepare (SV *cb) |
|
|
975 | PROTOTYPE: & |
|
|
976 | CODE: |
|
|
977 | SvREFCNT_dec (prepare_cb); |
|
|
978 | prepare_cb = newSVsv (cb); |
786 | |
979 | |
|
|
980 | DB_ENV * |
|
|
981 | db_env_create (U32 env_flags = 0) |
|
|
982 | CODE: |
|
|
983 | { |
|
|
984 | errno = db_env_create (&RETVAL, env_flags); |
|
|
985 | if (errno) |
|
|
986 | croak ("db_env_create: %s", db_strerror (errno)); |
|
|
987 | } |
|
|
988 | OUTPUT: |
|
|
989 | RETVAL |
|
|
990 | |
|
|
991 | void |
|
|
992 | db_env_open (DB_ENV *env, octetstring db_home, U32 open_flags, int mode, SV *callback = &PL_sv_undef) |
|
|
993 | CODE: |
|
|
994 | { |
|
|
995 | dREQ (REQ_ENV_OPEN); |
|
|
996 | req->env = env; |
|
|
997 | req->uint1 = open_flags | DB_THREAD; |
|
|
998 | req->int1 = mode; |
|
|
999 | req->buf1 = strdup_ornull (db_home); |
|
|
1000 | REQ_SEND; |
|
|
1001 | } |
|
|
1002 | |
|
|
1003 | void |
|
|
1004 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = &PL_sv_undef) |
|
|
1005 | CODE: |
|
|
1006 | { |
|
|
1007 | dREQ (REQ_ENV_CLOSE); |
|
|
1008 | req->env = env; |
|
|
1009 | req->uint1 = flags; |
|
|
1010 | REQ_SEND; |
|
|
1011 | } |
|
|
1012 | |
|
|
1013 | DB * |
|
|
1014 | db_create (DB_ENV *env = 0, U32 flags = 0) |
|
|
1015 | CODE: |
|
|
1016 | { |
|
|
1017 | errno = db_create (&RETVAL, env, flags); |
|
|
1018 | if (errno) |
|
|
1019 | croak ("db_env_create: %s", db_strerror (errno)); |
|
|
1020 | } |
|
|
1021 | OUTPUT: |
|
|
1022 | RETVAL |
|
|
1023 | |
|
|
1024 | void |
|
|
1025 | db_open (DB *db, DB_TXN *txnid, octetstring file, octetstring database, int type, U32 flags, int mode, SV *callback = &PL_sv_undef) |
|
|
1026 | CODE: |
|
|
1027 | { |
|
|
1028 | dREQ (REQ_DB_OPEN); |
|
|
1029 | req->db = db; |
|
|
1030 | req->txn = txnid; |
|
|
1031 | req->buf1 = strdup_ornull (file); |
|
|
1032 | req->buf2 = strdup_ornull (database); |
|
|
1033 | req->int1 = type; |
|
|
1034 | req->uint1 = flags | DB_THREAD; |
|
|
1035 | req->int2 = mode; |
|
|
1036 | REQ_SEND; |
|
|
1037 | } |
|
|
1038 | |
|
|
1039 | void |
|
|
1040 | db_close (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
|
|
1041 | CODE: |
|
|
1042 | { |
|
|
1043 | dREQ (REQ_DB_CLOSE); |
|
|
1044 | req->db = db; |
|
|
1045 | req->uint1 = flags; |
|
|
1046 | REQ_SEND; |
|
|
1047 | } |
|
|
1048 | |
|
|
1049 | void |
|
|
1050 | db_compact (DB *db, DB_TXN *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = &PL_sv_undef) |
|
|
1051 | CODE: |
|
|
1052 | { |
|
|
1053 | dREQ (REQ_DB_COMPACT); |
|
|
1054 | req->db = db; |
|
|
1055 | req->txn = txn; |
|
|
1056 | set_dbt (&req->dbt1, start); |
|
|
1057 | set_dbt (&req->dbt2, stop); |
|
|
1058 | req->uint1 = flags; |
|
|
1059 | REQ_SEND; |
|
|
1060 | } |
|
|
1061 | |
|
|
1062 | void |
|
|
1063 | db_sync (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
|
|
1064 | CODE: |
|
|
1065 | { |
|
|
1066 | dREQ (REQ_DB_SYNC); |
|
|
1067 | req->db = db; |
|
|
1068 | req->uint1 = flags; |
|
|
1069 | REQ_SEND; |
|
|
1070 | } |
|
|
1071 | |
|
|
1072 | void |
|
|
1073 | db_put (DB *db, DB_TXN *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
|
|
1074 | CODE: |
|
|
1075 | { |
|
|
1076 | dREQ (REQ_DB_PUT); |
|
|
1077 | req->db = db; |
|
|
1078 | req->txn = 0; |
|
|
1079 | set_dbt (&req->dbt1, key); |
|
|
1080 | set_dbt (&req->dbt2, data); |
|
|
1081 | req->uint1 = flags; |
|
|
1082 | REQ_SEND; |
|
|
1083 | } |
|
|
1084 | |
|
|
1085 | |
|
|
1086 | MODULE = BDB PACKAGE = BDB::Env |
|
|
1087 | |
|
|
1088 | int set_cachesize (DB_ENV *env, U32 gbytes, U32 bytes, int ncache = 0) |
|
|
1089 | CODE: |
|
|
1090 | RETVAL = env->set_cachesize (env, gbytes, bytes, ncache); |
|
|
1091 | OUTPUT: |
|
|
1092 | RETVAL |
|
|
1093 | |
|
|
1094 | int set_flags (DB_ENV *env, U32 flags, int onoff) |
|
|
1095 | CODE: |
|
|
1096 | RETVAL = env->set_flags (env, flags, onoff); |
|
|
1097 | OUTPUT: |
|
|
1098 | RETVAL |
|
|
1099 | |
|
|
1100 | int set_encrypt (DB_ENV *env, const char *password, U32 flags = 0) |
|
|
1101 | CODE: |
|
|
1102 | RETVAL = env->set_encrypt (env, password, flags); |
|
|
1103 | OUTPUT: |
|
|
1104 | RETVAL |
|
|
1105 | |
|
|
1106 | int set_timeout (DB_ENV *env, NV timeout, U32 flags) |
|
|
1107 | CODE: |
|
|
1108 | RETVAL = env->set_timeout (env, timeout * 1000000, flags); |
|
|
1109 | OUTPUT: |
|
|
1110 | RETVAL |
|
|
1111 | |
|
|
1112 | |
|
|
1113 | MODULE = BDB PACKAGE = BDB::Db |
|
|
1114 | |
|
|
1115 | int set_cachesize (DB *db, U32 gbytes, U32 bytes, int ncache = 0) |
|
|
1116 | CODE: |
|
|
1117 | RETVAL = db->set_cachesize (db, gbytes, bytes, ncache); |
|
|
1118 | OUTPUT: |
|
|
1119 | RETVAL |
|
|
1120 | |
|
|
1121 | int set_flags (DB *db, U32 flags); |
|
|
1122 | CODE: |
|
|
1123 | RETVAL = db->set_flags (db, flags); |
|
|
1124 | OUTPUT: |
|
|
1125 | RETVAL |
|
|
1126 | |
|
|
1127 | int set_encrypt (DB *db, const char *password, U32 flags) |
|
|
1128 | CODE: |
|
|
1129 | RETVAL = db->set_encrypt (db, password, flags); |
|
|
1130 | OUTPUT: |
|
|
1131 | RETVAL |
|
|
1132 | |
|
|
1133 | int set_lorder (DB *db, int lorder) |
|
|
1134 | CODE: |
|
|
1135 | RETVAL = db->set_lorder (db, lorder); |
|
|
1136 | OUTPUT: |
|
|
1137 | RETVAL |
|
|
1138 | |
|
|
1139 | |
|
|
1140 | int set_bt_minkey (DB *db, U32 minkey) |
|
|
1141 | CODE: |
|
|
1142 | RETVAL = db->set_bt_minkey (db, minkey); |
|
|
1143 | OUTPUT: |
|
|
1144 | RETVAL |
|
|
1145 | |
|
|
1146 | int set_re_delim(DB *db, int delim); |
|
|
1147 | CODE: |
|
|
1148 | RETVAL = db->set_re_delim (db, delim); |
|
|
1149 | OUTPUT: |
|
|
1150 | RETVAL |
|
|
1151 | |
|
|
1152 | int set_re_pad (DB *db, int re_pad) |
|
|
1153 | CODE: |
|
|
1154 | RETVAL = db->set_re_pad (db, re_pad); |
|
|
1155 | OUTPUT: |
|
|
1156 | RETVAL |
|
|
1157 | |
|
|
1158 | int set_re_source (DB *db, char *source) |
|
|
1159 | CODE: |
|
|
1160 | RETVAL = db->set_re_source (db, source); |
|
|
1161 | OUTPUT: |
|
|
1162 | RETVAL |
|
|
1163 | |
|
|
1164 | int set_re_len (DB *db, U32 re_len) |
|
|
1165 | CODE: |
|
|
1166 | RETVAL = db->set_re_len (db, re_len); |
|
|
1167 | OUTPUT: |
|
|
1168 | RETVAL |
|
|
1169 | |
|
|
1170 | int set_h_ffactor (DB *db, U32 h_ffactor) |
|
|
1171 | CODE: |
|
|
1172 | RETVAL = db->set_h_ffactor (db, h_ffactor); |
|
|
1173 | OUTPUT: |
|
|
1174 | RETVAL |
|
|
1175 | |
|
|
1176 | int set_h_nelem (DB *db, U32 h_nelem) |
|
|
1177 | CODE: |
|
|
1178 | RETVAL = db->set_h_nelem (db, h_nelem); |
|
|
1179 | OUTPUT: |
|
|
1180 | RETVAL |
|
|
1181 | |
|
|
1182 | int set_q_extentsize (DB *db, U32 extentsize) |
|
|
1183 | CODE: |
|
|
1184 | RETVAL = db->set_q_extentsize (db, extentsize); |
|
|
1185 | OUTPUT: |
|
|
1186 | RETVAL |
|
|
1187 | |
|
|
1188 | |