Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CBRD-20156] introduce light weight rwlock #9

Merged
merged 7 commits into from Apr 12, 2016
2 changes: 2 additions & 0 deletions src/communication/network_interface_sr.c
Expand Up @@ -7263,6 +7263,8 @@ sthread_dump_cs_stat (THREAD_ENTRY * thread_p, unsigned int rid, char *request,
}

csect_dump_statistics (outfp);
rwlock_dump_statistics (outfp);

file_size = ftell (outfp);

/*
Expand Down
7 changes: 7 additions & 0 deletions src/communication/network_sr.c
Expand Up @@ -1397,6 +1397,12 @@ net_server_start (const char *server_name)
status = -1;
goto end;
}
if (rwlock_initialize_rwlock_monitor () != NO_ERROR)
{
PRINT_AND_LOG_ERR_MSG ("Failed to initialize rwlock monitor\n");
status = -1;
goto end;
}
if (thread_initialize_manager () != NO_ERROR)
{
PRINT_AND_LOG_ERR_MSG ("Failed to initialize thread manager\n");
Expand Down Expand Up @@ -1466,6 +1472,7 @@ net_server_start (const char *server_name)
}

thread_final_manager ();
(void) rwlock_finalize_rwlock_monitor ();
csect_finalize ();

end:
Expand Down
2 changes: 1 addition & 1 deletion src/connection/connection_defs.h
Expand Up @@ -447,7 +447,7 @@ struct css_conn_entry
#if defined(SERVER_MODE)
int idx; /* connection index */
BOOT_CLIENT_TYPE client_type;
CSS_CRITICAL_SECTION csect;
CRITICAL_SECTION csect;
bool stop_talk; /* block and stop this connection */
bool ignore_repl_delay; /* don't do reset_on_commit by the delay of replication */
unsigned short stop_phase;
Expand Down
48 changes: 24 additions & 24 deletions src/connection/connection_sr.c
Expand Up @@ -327,7 +327,7 @@ css_shutdown_conn (CSS_CONN_ENTRY * conn)
#if defined(SERVER_MODE)
/* conn->csect.cs_index may equal to -1 and conn->csect.name may be NULL when initializing temp_conn in
* css_process_new_client */
assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == css_Csect_name_conn)
assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == csect_Name_conn)
|| (conn->csect.cs_index == -1 && conn->csect.name == NULL));
#endif
csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
Expand Down Expand Up @@ -406,7 +406,7 @@ css_shutdown_conn (CSS_CONN_ENTRY * conn)
conn->session_id = DB_EMPTY_SESSION;
}

assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == css_Csect_name_conn)
assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == csect_Name_conn)
|| (conn->csect.cs_index == -1 && conn->csect.name == NULL));
#endif
csect_exit_critical_section (NULL, &conn->csect);
Expand Down Expand Up @@ -460,7 +460,7 @@ css_init_conn_list (void)
assert (conn->csect.name == NULL);

conn->csect.cs_index = CRITICAL_SECTION_COUNT + conn->idx;
conn->csect.name = css_Csect_name_conn;
conn->csect.name = csect_Name_conn;
#endif
}
else
Expand Down Expand Up @@ -523,7 +523,7 @@ css_final_conn_list (void)
#if defined(SERVER_MODE)
assert (conn->idx == i);
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_finalize_critical_section (&conn->csect);
Expand Down Expand Up @@ -1343,7 +1343,7 @@ css_get_request_id (CSS_CONN_ENTRY * conn)

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif
csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);

Expand All @@ -1361,7 +1361,7 @@ css_get_request_id (CSS_CONN_ENTRY * conn)

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand All @@ -1379,7 +1379,7 @@ css_get_request_id (CSS_CONN_ENTRY * conn)

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand Down Expand Up @@ -1437,7 +1437,7 @@ css_send_abort_request (CSS_CONN_ENTRY * conn, unsigned short request_id)

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
Expand All @@ -1447,7 +1447,7 @@ css_send_abort_request (CSS_CONN_ENTRY * conn, unsigned short request_id)

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand Down Expand Up @@ -1918,7 +1918,7 @@ css_queue_packet (CSS_CONN_ENTRY * conn, int type, unsigned short request_id, co

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
Expand Down Expand Up @@ -1976,7 +1976,7 @@ css_queue_packet (CSS_CONN_ENTRY * conn, int type, unsigned short request_id, co

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand Down Expand Up @@ -2282,7 +2282,7 @@ css_return_queued_request (CSS_CONN_ENTRY * conn, unsigned short *rid, int *requ

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
Expand Down Expand Up @@ -2318,7 +2318,7 @@ css_return_queued_request (CSS_CONN_ENTRY * conn, unsigned short *rid, int *requ

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand Down Expand Up @@ -2384,7 +2384,7 @@ css_return_queued_data_timeout (CSS_CONN_ENTRY * conn, unsigned short rid, char

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

/* enter the critical section of this connection */
Expand Down Expand Up @@ -2436,7 +2436,7 @@ css_return_queued_data_timeout (CSS_CONN_ENTRY * conn, unsigned short rid, char

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand All @@ -2460,7 +2460,7 @@ css_return_queued_data_timeout (CSS_CONN_ENTRY * conn, unsigned short rid, char
{
#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

/* exit the critical section before to be suspended */
Expand Down Expand Up @@ -2528,7 +2528,7 @@ css_return_queued_data_timeout (CSS_CONN_ENTRY * conn, unsigned short rid, char
{
#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

clear_wait_queue_entry_and_free_buffer (thrd, conn, rid, buffer);
Expand All @@ -2553,7 +2553,7 @@ css_return_queued_data_timeout (CSS_CONN_ENTRY * conn, unsigned short rid, char

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

/* exit the critical section */
Expand Down Expand Up @@ -2593,7 +2593,7 @@ css_return_queued_error (CSS_CONN_ENTRY * conn, unsigned short request_id, char

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
Expand All @@ -2610,7 +2610,7 @@ css_return_queued_error (CSS_CONN_ENTRY * conn, unsigned short request_id, char

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand Down Expand Up @@ -2698,7 +2698,7 @@ css_queue_user_data_buffer (CSS_CONN_ENTRY * conn, unsigned short request_id, in

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
Expand All @@ -2712,7 +2712,7 @@ css_queue_user_data_buffer (CSS_CONN_ENTRY * conn, unsigned short request_id, in

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand Down Expand Up @@ -2756,7 +2756,7 @@ css_remove_all_unexpected_packets (CSS_CONN_ENTRY * conn)
#if defined(SERVER_MODE)
/* conn->csect.cs_index may equal to -1 and conn->csect.name may be NULL when initializing temp_conn in
* css_process_new_client */
assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == css_Csect_name_conn)
assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == csect_Name_conn)
|| (conn->csect.cs_index == -1 && conn->csect.name == NULL));
#endif

Expand All @@ -2773,7 +2773,7 @@ css_remove_all_unexpected_packets (CSS_CONN_ENTRY * conn)
css_traverse_list (&conn->error_queue, css_remove_and_free_queue_entry, conn);

#if defined(SERVER_MODE)
assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == css_Csect_name_conn)
assert ((conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx && conn->csect.name == csect_Name_conn)
|| (conn->csect.cs_index == -1 && conn->csect.name == NULL));
#endif

Expand Down
15 changes: 7 additions & 8 deletions src/connection/server_support.c
Expand Up @@ -1681,15 +1681,15 @@ css_block_all_active_conn (unsigned short stop_phase)
{
#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
if (conn->stop_phase != stop_phase)
{
#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand All @@ -1704,7 +1704,7 @@ css_block_all_active_conn (unsigned short stop_phase)

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand All @@ -1728,9 +1728,8 @@ css_internal_connection_handler (CSS_CONN_ENTRY * conn)

css_insert_into_active_conn_list (conn);

job = css_make_job_entry (conn, (CSS_THREAD_FN) css_connection_handler_thread, (CSS_THREAD_ARG) conn, -1 /* implicit:
* DEFAULT
*/ );
job = css_make_job_entry (conn, (CSS_THREAD_FN) css_connection_handler_thread, (CSS_THREAD_ARG) conn,
-1 /* implicit: DEFAULT */ );
assert (job != NULL);

if (job != NULL)
Expand Down Expand Up @@ -2310,7 +2309,7 @@ css_end_server_request (CSS_CONN_ENTRY * conn)
{
#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_enter_critical_section (NULL, &conn->csect, INF_WAIT);
Expand All @@ -2320,7 +2319,7 @@ css_end_server_request (CSS_CONN_ENTRY * conn)

#if defined(SERVER_MODE)
assert (conn->csect.cs_index == CRITICAL_SECTION_COUNT + conn->idx);
assert (conn->csect.name == css_Csect_name_conn);
assert (conn->csect.name == csect_Name_conn);
#endif

csect_exit_critical_section (NULL, &conn->csect);
Expand Down