MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / fstdump_thread

Function fstdump_thread

bdb/fstdump.c:231–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231static void *fstdump_thread(void *arg)
232{
233 fstdump_per_thread_t *fstdump = (fstdump_per_thread_t *)arg;
234 fstdump_t *common = fstdump->common;
235 void *ret = NULL;
236 void *sendrec;
237 void *databuf;
238 size_t buffer_length;
239 bdb_state_type *bdb_state = common->bdb_state;
240
241 /*thread_started("bdb fstdump");*/
242
243 /* work out how large a buffer we need. It must be a multiple of 1KB,
244 * larger than the page size and unsigned int aligned
245 * (see berkdb docs). */
246 buffer_length = bdb_state->attr->fstdump_buffer_length;
247 if ((buffer_length & (1024 - 1)) != 0)
248 buffer_length &= ~(1024 - 1);
249 if (buffer_length < bdb_state->attr->pagesizedta)
250 buffer_length = bdb_state->attr->pagesizedta;
251
252 sendrec = mymalloc(common->sendrecsz);
253 if (!sendrec)
254 logmsg(LOGMSG_ERROR, "fstdump_thread: mymalloc %zu failed (sendrec)\n",
255 common->sendrecsz);
256 databuf = mymalloc(buffer_length);
257 if (!databuf)
258 logmsg(LOGMSG_ERROR, "fstdump_thread: mymalloc %u failed (databuf)\n",
259 (unsigned)buffer_length);
260
261 if (sendrec && databuf) {
262 /* If not threaded then read lock etc already acquired */
263 if (fstdump->real_thread) {
264 bdb_thread_event(common->bdb_state, BDBTHR_EVENT_START_RDONLY);
265 BDB_READLOCK("fstdump_thread");
266 }
267
268 ret = fstdump_thread_inner(fstdump, sendrec, databuf, buffer_length);
269
270 if (fstdump->real_thread) {
271 BDB_RELLOCK();
272 bdb_thread_event(common->bdb_state, BDBTHR_EVENT_DONE_RDONLY);
273 }
274 } else {
275 Pthread_mutex_lock(&common->lock);
276 {
277 common->bdberr = BDBERR_MALLOC;
278 snprintf0(common->errmsg, sizeof(common->errmsg), "out of memory");
279 }
280 Pthread_mutex_unlock(&common->lock);
281 }
282
283 if (sendrec)
284 free(sendrec);
285 if (databuf)
286 free(databuf);
287
288 return ret;

Callers 2

fstdump_thread2Function · 0.85

Calls 6

mymallocFunction · 0.85
bdb_thread_eventFunction · 0.85
fstdump_thread_innerFunction · 0.85
snprintf0Function · 0.85
freeFunction · 0.85
logmsgFunction · 0.50

Tested by

no test coverage detected