Remove unused skygw_-functions
This commit is contained in:
@ -40,15 +40,6 @@ typedef struct simple_mutex_st
|
|||||||
skygw_chk_t sm_chk_tail;
|
skygw_chk_t sm_chk_tail;
|
||||||
} simple_mutex_t;
|
} simple_mutex_t;
|
||||||
|
|
||||||
typedef struct skygw_rwlock_st
|
|
||||||
{
|
|
||||||
skygw_chk_t srw_chk_top;
|
|
||||||
pthread_rwlock_t* srw_rwlock;
|
|
||||||
pthread_t srw_rwlock_thr;
|
|
||||||
skygw_chk_t srw_chk_tail;
|
|
||||||
} skygw_rwlock_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum { THR_INIT, THR_RUNNING, THR_STOPPED, THR_DONE } skygw_thr_state_t;
|
typedef enum { THR_INIT, THR_RUNNING, THR_STOPPED, THR_DONE } skygw_thr_state_t;
|
||||||
typedef enum { MES_RC_FAIL, MES_RC_SUCCESS, MES_RC_TIMEOUT } skygw_mes_rc_t;
|
typedef enum { MES_RC_FAIL, MES_RC_SUCCESS, MES_RC_TIMEOUT } skygw_mes_rc_t;
|
||||||
|
|
||||||
@ -158,11 +149,6 @@ void skygw_message_reset(skygw_message_t* mes);
|
|||||||
|
|
||||||
/** Skygw message routines */
|
/** Skygw message routines */
|
||||||
|
|
||||||
int skygw_rwlock_wrlock(skygw_rwlock_t* rwlock);
|
|
||||||
int skygw_rwlock_rdlock(skygw_rwlock_t* rwlock);
|
|
||||||
int skygw_rwlock_unlock(skygw_rwlock_t* rwlock);
|
|
||||||
int skygw_rwlock_init(skygw_rwlock_t** rwlock);
|
|
||||||
|
|
||||||
size_t get_decimal_len(size_t s);
|
size_t get_decimal_len(size_t s);
|
||||||
|
|
||||||
MXS_END_DECLS
|
MXS_END_DECLS
|
||||||
|
@ -43,117 +43,6 @@ static void simple_mutex_free_memory(simple_mutex_t* sm);
|
|||||||
static void thread_free_memory(skygw_thread_t* th, char* name);
|
static void thread_free_memory(skygw_thread_t* th, char* name);
|
||||||
/** End of static function declarations */
|
/** End of static function declarations */
|
||||||
|
|
||||||
|
|
||||||
int skygw_rwlock_rdlock(skygw_rwlock_t* rwlock)
|
|
||||||
{
|
|
||||||
int err = pthread_rwlock_rdlock(rwlock->srw_rwlock);
|
|
||||||
|
|
||||||
if (err == 0)
|
|
||||||
{
|
|
||||||
rwlock->srw_rwlock_thr = pthread_self();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rwlock->srw_rwlock_thr = 0;
|
|
||||||
ss_dfprintf(stderr,
|
|
||||||
"* pthread_rwlock_rdlock : %s\n",
|
|
||||||
mxs_strerror(err));
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
int skygw_rwlock_wrlock(skygw_rwlock_t* rwlock)
|
|
||||||
{
|
|
||||||
int err = pthread_rwlock_wrlock(rwlock->srw_rwlock);
|
|
||||||
|
|
||||||
if (err == 0)
|
|
||||||
{
|
|
||||||
rwlock->srw_rwlock_thr = pthread_self();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rwlock->srw_rwlock_thr = 0;
|
|
||||||
ss_dfprintf(stderr,
|
|
||||||
"* pthread_rwlock_wrlock : %s\n",
|
|
||||||
mxs_strerror(err));
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
int skygw_rwlock_unlock(skygw_rwlock_t* rwlock)
|
|
||||||
{
|
|
||||||
int err = pthread_rwlock_rdlock(rwlock->srw_rwlock);
|
|
||||||
|
|
||||||
if (err == 0)
|
|
||||||
{
|
|
||||||
rwlock->srw_rwlock_thr = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ss_dfprintf(stderr, "* pthread_rwlock_unlock : %s\n",
|
|
||||||
mxs_strerror(err));
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
int skygw_rwlock_destroy(skygw_rwlock_t* rwlock)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
/** Lock */
|
|
||||||
if ((err = pthread_rwlock_wrlock(rwlock->srw_rwlock)) != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "* Error : pthread_rwlock_wrlock failed due to %d, %s.\n",
|
|
||||||
err, mxs_strerror(err));
|
|
||||||
goto retblock;
|
|
||||||
}
|
|
||||||
/** Clean the struct */
|
|
||||||
rwlock->srw_rwlock_thr = 0;
|
|
||||||
/** Unlock */
|
|
||||||
pthread_rwlock_unlock(rwlock->srw_rwlock);
|
|
||||||
/** Destroy */
|
|
||||||
if ((err = pthread_rwlock_destroy(rwlock->srw_rwlock)) != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "* Error : pthread_rwlock_destroy failed due to %d,%s\n",
|
|
||||||
err, mxs_strerror(err));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rwlock->srw_rwlock = NULL;
|
|
||||||
}
|
|
||||||
retblock:
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
int skygw_rwlock_init(skygw_rwlock_t** rwlock)
|
|
||||||
{
|
|
||||||
skygw_rwlock_t* rwl;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
rwl = (skygw_rwlock_t *) calloc(1, sizeof (skygw_rwlock_t));
|
|
||||||
|
|
||||||
if (rwl == NULL)
|
|
||||||
{
|
|
||||||
err = 1;
|
|
||||||
goto return_err;
|
|
||||||
}
|
|
||||||
rwl->srw_chk_top = CHK_NUM_RWLOCK;
|
|
||||||
rwl->srw_chk_tail = CHK_NUM_RWLOCK;
|
|
||||||
err = pthread_rwlock_init(rwl->srw_rwlock, NULL);
|
|
||||||
ss_dassert(err == 0);
|
|
||||||
|
|
||||||
if (err != 0)
|
|
||||||
{
|
|
||||||
free(rwl);
|
|
||||||
ss_dfprintf(stderr, "* Creating pthread_rwlock failed : %s\n",
|
|
||||||
mxs_strerror(err));
|
|
||||||
goto return_err;
|
|
||||||
}
|
|
||||||
*rwlock = rwl;
|
|
||||||
|
|
||||||
return_err:
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_timestamp_len(void)
|
size_t get_timestamp_len(void)
|
||||||
{
|
{
|
||||||
return timestamp_len;
|
return timestamp_len;
|
||||||
|
Reference in New Issue
Block a user