77 #include <sys/types.h> 78 #include <sys/socket.h> 105 unsigned char buf[4];
120 unsigned char buf[4];
126 error(0,
"Packet too short while unpacking Msg.");
150 error(errno,
"Failed to open '%s' for writing, cannot create store-file",
161 if (errno != ENOENT) {
162 error(errno,
"Failed to rename old store '%s' as '%s'",
168 error(errno,
"Failed to rename new store '%s' as '%s'",
304 time(&
msg->sms.time);
321 warning(0,
"bb_store: get ACK of message not found " 322 "from store, strange?");
372 mack->ack.time =
msg->sms.time;
401 if (store_file != NULL)
405 if (store_file != NULL)
409 if (store_file != NULL)
412 info(0,
"Cannot open any store file, starting a new one");
419 info(0,
"Store-file size %ld, starting to unpack%s",
octstr_len(store_file),
420 octstr_len(store_file) > 10000 ?
" (may take awhile)" :
"");
429 error(0,
"Garbage at store-file, skipped.");
438 warning(0,
"Strange message in store-file, discarded, " 446 info(0,
"Retrieved %d messages, non-acknowledged messages: %ld",
457 error(0,
"Found unknown message type in store file.");
476 panic(0,
"Failed to create a cleanup thread!");
486 debug(
"bb.store", 0,
"Dumping %ld messages to store",
530 panic(0,
"Store file filename too long: `%s', failed to init.",
Dict * dict_create(long size_hint, void(*destroy_value)(void *))
void msg_dump(Msg *msg, int level)
void error(int err, const char *fmt,...)
void info(int err, const char *fmt,...)
Msg * msg_duplicate(Msg *msg)
static long store_file_messages(void)
static int read_msg(Msg **msg, Octstr *os, long *off)
static void store_file_shutdown(void)
gw_assert(wtls_machine->packet_to_send !=NULL)
void dict_put(Dict *dict, Octstr *key, void *value)
void encode_network_long(unsigned char *data, unsigned long value)
int store_file_init(const Octstr *fname, long dump_freq)
void gwthread_join(long thread)
long gwlist_len(List *list)
int(* store_save_ack)(Msg *msg, ack_status_t status)
static long dump_frequency
void * gwlist_get(List *list, long pos)
long(* store_messages)(void)
static void write_msg(Msg *msg)
void uuid_unparse(const uuid_t uu, char *out)
int octstr_print(FILE *f, Octstr *ostr)
void uuid_generate(uuid_t out)
static int store_file_dump(void)
Msg *(* store_msg_unpack)(Octstr *os)
static int store_to_dict(Msg *msg)
void octstr_insert_data(Octstr *ostr, long pos, const char *data, long len)
#define octstr_get_cstr(ostr)
#define octstr_copy(ostr, from, len)
void(* store_for_each_message)(void(*callback_fn)(Msg *msg, void *data), void *data)
static int rename_store(void)
void msg_destroy_item(void *msg)
#define BB_STORE_DEFAULT_DUMP_FREQ
void * dict_remove(Dict *dict, Octstr *key)
void * gwlist_extract_first(List *list)
static int store_file_save_ack(Msg *msg, ack_status_t status)
void * dict_get(Dict *dict, Octstr *key)
void gwlist_remove_producer(List *list)
int uuid_is_null(const uuid_t uu)
#define octstr_duplicate(ostr)
static time_t last_dict_mod
long dict_key_count(Dict *dict)
static int store_file_save(Msg *msg)
void uuid_copy(uuid_t dst, const uuid_t src)
void msg_destroy(Msg *msg)
void warning(int err, const char *fmt,...)
static long cleanup_thread
Octstr * octstr_format(const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define gwthread_create(func, arg)
#define octstr_create(cstr)
void octstr_destroy_item(void *os)
void gwthread_sleep(double seconds)
void mutex_destroy(Mutex *mutex)
Octstr *(* store_msg_pack)(Msg *msg)
static Mutex * file_mutex
Octstr * octstr_read_file(const char *filename)
void(* store_shutdown)(void)
long octstr_len(const Octstr *ostr)
void dict_destroy(Dict *dict)
long decode_network_long(unsigned char *data)
static void store_file_for_each_message(void(*callback_fn)(Msg *msg, void *data), void *data)
void * gwlist_consume(List *list)
static int open_file(Octstr *name)
void debug(const char *place, int err, const char *fmt,...)
void gwthread_wakeup(long thread)
int(* store_load)(void(*receive_msg)(Msg *))
#define MSG_PARAM_UNDEFINED
List * dict_keys(Dict *dict)
void(* callback_fn)(Msg *msg, void *data)
int(* store_save)(Msg *msg)
static int store_file_load(void(*receive_msg)(Msg *))
void gwlist_add_producer(List *list)
void octstr_get_many_chars(char *buf, Octstr *ostr, long pos, long len)
static XMLRPCDocument * msg
static void store_dumper(void *arg)
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)