library/src/network/httpd/BP-HTTPdRequests.cc
// Attempts to destroy a request (called after a request is dispatched automatically, shouldn't be called
// directly unless you know what you're doing).  Destroys all relevant data.
Attempts to destroy a request (called after a request is dispatched automatically, shouldn't be called
directly unless you know what you're doing).  Destroys all relevant data.
Attempts to destroy a request ( called after a request is dispatched automatically shouldn ' t be called directly unless you know what you ' re doing ) . Destroys all relevant data .
BP_ERROR_T BP_HTTPdRequestDestroy(P_BP_HTTPD_SESSION httpd, P_BP_HTTPD_REQUEST request)
{
	if(!httpd)
		return ERR_FAILURE;
	if(!httpd->request_hreg)
		return ERR_FAILURE;
	if(!request)
		return ERR_FAILURE;
	char * table_path[10] = {0};
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(httpd->request_hreg);
	if(request->arg_hreg)
	{
		BP_HTTPdRequestDestroyArgRegistry(request);
	}
	if(request->json_output)
	{
		BP_JSONDestroy(request->json_output);
	}
	if(request->hostname)
	{
		bpfree(request->hostname);
		request->hostname = NULL;
	}
	if(request->ip_address)
	{
		bpfree(request->ip_address);
		request->ip_address = NULL;
	}
	if(request->pp)
	{
		MHD_destroy_post_processor(request->pp);
		request->pp = NULL;
	}
	if(request->post_uploaded_full_file_path)
	{
		bpfree(request->post_uploaded_full_file_path);
		request->post_uploaded_full_file_path = NULL;
	}
	char saved_uuid[BP_UUID_LEN+10];
	BP_ZERO_STACK(saved_uuid);
	if(request->uuid)
	{
		memcpy((char *) &saved_uuid, request->uuid, BP_UUID_LEN);
		bpfree(request->uuid);
		request->uuid = NULL;
	}
	table_path[0] = "requests";
	table_path[1] = (char *) &saved_uuid;
	table_path[2] = NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY request_entry = BP_HashRegLookupTableEntryByPath(httpd->request_hreg, table_path);
	if(!request_entry)
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(httpd->request_hreg, ERR_FAILURE);
	BP_HashRegDestroyEntry(httpd->request_hreg, request_entry);
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(httpd->request_hreg);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_HTTPdRequestDestroy ( P_BP_HTTPD_SESSION httpd , P_BP_HTTPD_REQUEST request ) { if ( ! httpd ) return ERR_FAILURE ; if ( ! httpd -> request_hreg ) return ERR_FAILURE ; if ( ! request ) return ERR_FAILURE ; char * table_path [ 10 ] = { 0 } ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( httpd -> request_hreg ) ; if ( request -> arg_hreg ) { BP_HTTPdRequestDestroyArgRegistry ( request ) ; } if ( request -> json_output ) { BP_JSONDestroy ( request -> json_output ) ; } if ( request -> hostname ) { bpfree ( request -> hostname ) ; request -> hostname = NULL ; } if ( request -> ip_address ) { bpfree ( request -> ip_address ) ; request -> ip_address = NULL ; } if ( request -> pp ) { MHD_destroy_post_processor ( request -> pp ) ; request -> pp = NULL ; } if ( request -> post_uploaded_full_file_path ) { bpfree ( request -> post_uploaded_full_file_path ) ; request -> post_uploaded_full_file_path = NULL ; } char saved_uuid [ BP_UUID_LEN + 10 ] ; BP_ZERO_STACK ( saved_uuid ) ; if ( request -> uuid ) { memcpy ( ( char * ) & saved_uuid , request -> uuid , BP_UUID_LEN ) ; bpfree ( request -> uuid ) ; request -> uuid = NULL ; } table_path [ 0 ] = " " ; table_path [ 1 ] = ( char * ) & saved_uuid ; table_path [ 2 ] = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY request_entry = BP_HashRegLookupTableEntryByPath ( httpd -> request_hreg , table_path ) ; if ( ! request_entry ) BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( httpd -> request_hreg , ERR_FAILURE ) ; BP_HashRegDestroyEntry ( httpd -> request_hreg , request_entry ) ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( httpd -> request_hreg ) ; return ERR_SUCCESS ; }
Attempts to destroy a request (called after a request is dispatched automatically, shouldn't be called
directly unless you know what you're doing).
Attempts to destroy a request ( called after a request is dispatched automatically shouldn ' t be called directly unless you know what you ' re doing ) .
// declare dynamic table path // declare the lookup pointer // enter critical section before making changes to the httpd hash // table registry. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Destroy Arg Registry %%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Destroy Arguments First // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Destroy Output JSON if Necessary %%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // destroy output // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Destroy Member Data %%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // destroy hostname // destroy ip address // Destroy the libmicrohttpd post processor here (if it's set; it shouldn't be set) // destroy postprocessor here // set to null // destroy uploaded file full path if set (deprecated i think) // create space on stack to save the request uuid (needed for deletion) // save uuid if present (should always be present) // copy in the uuid (so we can delete it from parent hreg) // free heap memory // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Remove From Request Registry %%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set the requests table // attempt to lookup the entry to delete // if we can't look it up, exit immediately // destroy the entry // leave critical section // return indicating success