library/src/network/httpd/BP-HTTPdRequests.cc
// Attempts to create a new empty request structure.  This routine exists simply
// because the creation logic can be kinda long and it's better to have this logic
// isolated.  Makes the code easier to follow (it was previoulsy within BP_HTTPdRequestAdd).
Attempts to create a new empty request structure.  This routine exists simply
because the creation logic can be kinda long and it's better to have this logic
isolated.  Makes the code easier to follow (it was previoulsy within BP_HTTPdRequestAdd).
Attempts to create a new empty request structure . This routine exists simply because the creation logic can be kinda long and it ' s better to have this logic isolated . Makes the code easier to follow ( it was previoulsy within BP_HTTPdRequestAdd ) .
P_BP_HTTPD_REQUEST BP_HTTPdRequestCreateNewEmpty(P_BP_HTTPD_SESSION httpd)
{
	if(!httpd)
		return NULL;
	if(!httpd->request_hreg)
		return NULL;
	char * table_path[10] = {0};
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(httpd->request_hreg);
	table_path[0] = "requests";
	table_path[1] = NULL;
	char * new_uuid = BP_GenRandomUUID();
	BP_ERROR_T err_status = BP_HashRegAddDataToTableByPath
	(
		httpd->request_hreg,
		table_path,
		new_uuid,
		BP_HASH_TABLE_KEYED_ENTRY_TYPE_BINARY_BLOB,
		NULL,
		sizeof(BP_HTTPD_REQUEST)
	);
	P_BP_HTTPD_REQUEST request = BP_HTTPdRequestLookupByUUID(httpd, new_uuid);
	if(!request)
	{
		bpfree(new_uuid);
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(httpd->request_hreg, NULL);
	}
	request->uuid = new_uuid;
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(httpd->request_hreg);
	return request;
}
P_BP_HTTPD_REQUEST BP_HTTPdRequestCreateNewEmpty ( P_BP_HTTPD_SESSION httpd ) { if ( ! httpd ) return NULL ; if ( ! httpd -> request_hreg ) return NULL ; char * table_path [ 10 ] = { 0 } ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( httpd -> request_hreg ) ; table_path [ 0 ] = " " ; table_path [ 1 ] = NULL ; char * new_uuid = BP_GenRandomUUID ( ) ; BP_ERROR_T err_status = BP_HashRegAddDataToTableByPath ( httpd -> request_hreg , table_path , new_uuid , BP_HASH_TABLE_KEYED_ENTRY_TYPE_BINARY_BLOB , NULL , sizeof ( BP_HTTPD_REQUEST ) ) ; P_BP_HTTPD_REQUEST request = BP_HTTPdRequestLookupByUUID ( httpd , new_uuid ) ; if ( ! request ) { bpfree ( new_uuid ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( httpd -> request_hreg , NULL ) ; } request -> uuid = new_uuid ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( httpd -> request_hreg ) ; return request ; }
Attempts to create a new empty request structure.
Attempts to create a new empty request structure .
// declare dynamic table path // declare the lookup pointer // enter critical section before making changes to the httpd hash // table registry. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Attempt to Create New User Structure %%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set the initial path // generate new random uuid as unique key // attempt to add data to the table // lookup the request // set the new uuid in the request here // leave critical section // return the looked up request