MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / keycache_pthread_cond_wait

Function keycache_pthread_cond_wait

mysys/mf_keycache.c:4342–4388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4340
4341
4342static int keycache_pthread_cond_wait(mysql_cond_t *cond,
4343 mysql_mutex_t *mutex)
4344{
4345 int rc;
4346 struct timeval now; /* time when we started waiting */
4347 struct timespec timeout; /* timeout value for the wait function */
4348 struct timezone tz;
4349#if defined(KEYCACHE_DEBUG)
4350 int cnt=0;
4351#endif
4352
4353 /* Get current time */
4354 gettimeofday(&now, &tz);
4355 /* Prepare timeout value */
4356 timeout.tv_sec= now.tv_sec + KEYCACHE_TIMEOUT;
4357 /*
4358 timeval uses microseconds.
4359 timespec uses nanoseconds.
4360 1 nanosecond = 1000 micro seconds
4361 */
4362 timeout.tv_nsec= now.tv_usec * 1000;
4363 KEYCACHE_THREAD_TRACE_END("started waiting");
4364#if defined(KEYCACHE_DEBUG)
4365 cnt++;
4366 if (cnt % 100 == 0)
4367 fprintf(keycache_debug_log, "waiting...\n");
4368 fflush(keycache_debug_log);
4369#endif
4370 rc= mysql_cond_timedwait(cond, mutex, &timeout);
4371 KEYCACHE_THREAD_TRACE_BEGIN("finished waiting");
4372 if (rc == ETIMEDOUT || rc == ETIME)
4373 {
4374#if defined(KEYCACHE_DEBUG)
4375 fprintf(keycache_debug_log,"aborted by keycache timeout\n");
4376 fclose(keycache_debug_log);
4377 abort();
4378#endif
4379 keycache_dump();
4380 }
4381
4382#if defined(KEYCACHE_DEBUG)
4383 KEYCACHE_DBUG_ASSERT(rc != ETIMEDOUT);
4384#else
4385 assert(rc != ETIMEDOUT);
4386#endif
4387 return rc;
4388}
4389#else
4390#if defined(KEYCACHE_DEBUG)
4391static int keycache_pthread_cond_wait(mysql_cond_t *cond,

Callers 4

wait_on_queueFunction · 0.85
wait_for_readersFunction · 0.85
get_hash_linkFunction · 0.85
find_key_blockFunction · 0.85

Calls 1

keycache_dumpFunction · 0.85

Tested by

no test coverage detected