Skip to content
Snippets Groups Projects
Commit 597d95ad authored by ruslan.laishev's avatar ruslan.laishev 💬
Browse files

Features #5708 - added return code for the routines:

 dap_proc_queue_add_callback()
 dap_proc_queue_add_callback_inter()
 dap_proc_queue_delete ()
parent f83f4850
No related branches found
No related tags found
1 merge request!512bugfix-5760
Pipeline #12046 passed with stage
in 5 seconds
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
along with any DAP SDK based project. If not, see <http://www.gnu.org/licenses/>. along with any DAP SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <assert.h> #include <assert.h>
#include <errno.h>
#include "dap_worker.h" #include "dap_worker.h"
#include "dap_proc_queue.h" #include "dap_proc_queue.h"
#include "dap_proc_thread.h" #include "dap_proc_thread.h"
...@@ -42,23 +43,35 @@ static void s_queue_esocket_callback( dap_events_socket_t * a_es, void * a_msg); ...@@ -42,23 +43,35 @@ static void s_queue_esocket_callback( dap_events_socket_t * a_es, void * a_msg);
*/ */
dap_proc_queue_t * dap_proc_queue_create(dap_proc_thread_t * a_thread) dap_proc_queue_t * dap_proc_queue_create(dap_proc_thread_t * a_thread)
{ {
dap_proc_queue_t * l_queue = DAP_NEW_Z(dap_proc_queue_t); if (!l_queue) return NULL; dap_proc_queue_t * l_queue = DAP_NEW_Z(dap_proc_queue_t);
if (!l_queue)
return NULL;
l_queue->proc_thread = a_thread; l_queue->proc_thread = a_thread;
l_queue->esocket = dap_events_socket_create_type_queue_ptr_unsafe(NULL,s_queue_esocket_callback); l_queue->esocket = dap_events_socket_create_type_queue_ptr_unsafe(NULL,s_queue_esocket_callback);
l_queue->esocket->proc_thread = a_thread; l_queue->esocket->proc_thread = a_thread;
l_queue->esocket->_inheritor = l_queue; l_queue->esocket->_inheritor = l_queue;
return l_queue; return l_queue;
} }
/** /**
* @brief dap_proc_queue_delete * @brief dap_proc_queue_delete
* @param a_queue * @param a_queue
* @return: -ENOMEM in case of memory allocation error
* other <errno> codes from the internaly called routine
*/ */
void dap_proc_queue_delete(dap_proc_queue_t * a_queue) int dap_proc_queue_delete(dap_proc_queue_t * a_queue)
{ {
dap_proc_queue_msg_t * l_msg = DAP_NEW_Z(dap_proc_queue_msg_t); if(!l_msg) return; dap_proc_queue_msg_t * l_msg = DAP_NEW_Z(dap_proc_queue_msg_t);
if (!l_msg)
return -ENOMEM;
l_msg->signal_kill = true; l_msg->signal_kill = true;
dap_events_socket_queue_ptr_send( a_queue->esocket, l_msg );
return dap_events_socket_queue_ptr_send( a_queue->esocket, l_msg );
} }
/** /**
...@@ -100,6 +113,7 @@ static void s_queue_esocket_callback( dap_events_socket_t * a_es, void * a_msg) ...@@ -100,6 +113,7 @@ static void s_queue_esocket_callback( dap_events_socket_t * a_es, void * a_msg)
if (l_msg->signal_kill){ // Say to kill this object and delete its inherior dap_proc_queue_t if (l_msg->signal_kill){ // Say to kill this object and delete its inherior dap_proc_queue_t
a_es->flags |= DAP_SOCK_SIGNAL_CLOSE; a_es->flags |= DAP_SOCK_SIGNAL_CLOSE;
} }
DAP_DELETE(l_msg); DAP_DELETE(l_msg);
} }
...@@ -108,13 +122,20 @@ static void s_queue_esocket_callback( dap_events_socket_t * a_es, void * a_msg) ...@@ -108,13 +122,20 @@ static void s_queue_esocket_callback( dap_events_socket_t * a_es, void * a_msg)
* @param a_worker * @param a_worker
* @param a_callback * @param a_callback
* @param a_callback_arg * @param a_callback_arg
* @return: -ENOMEM in case of memory allocation error
* other <errno> codes from the internaly called routine
*/ */
void dap_proc_queue_add_callback(dap_worker_t * a_worker,dap_proc_queue_callback_t a_callback, void * a_callback_arg) int dap_proc_queue_add_callback(dap_worker_t * a_worker,dap_proc_queue_callback_t a_callback, void * a_callback_arg)
{ {
dap_proc_queue_msg_t * l_msg = DAP_NEW_Z(dap_proc_queue_msg_t); if (!l_msg) return; dap_proc_queue_msg_t * l_msg = DAP_NEW_Z(dap_proc_queue_msg_t);
if (!l_msg)
return -ENOMEM;
l_msg->callback = a_callback; l_msg->callback = a_callback;
l_msg->callback_arg = a_callback_arg; l_msg->callback_arg = a_callback_arg;
dap_events_socket_queue_ptr_send( a_worker->proc_queue->esocket , l_msg );
return dap_events_socket_queue_ptr_send( a_worker->proc_queue->esocket , l_msg );
} }
/** /**
...@@ -122,15 +143,18 @@ void dap_proc_queue_add_callback(dap_worker_t * a_worker,dap_proc_queue_callback ...@@ -122,15 +143,18 @@ void dap_proc_queue_add_callback(dap_worker_t * a_worker,dap_proc_queue_callback
* @param a_es_input * @param a_es_input
* @param a_callback * @param a_callback
* @param a_callback_arg * @param a_callback_arg
* @return: -ENOMEM in case of memory allocation error
* other <errno> codes from the internaly called routine
*/ */
void dap_proc_queue_add_callback_inter( dap_events_socket_t * a_es_input, dap_proc_queue_callback_t a_callback, void * a_callback_arg) int dap_proc_queue_add_callback_inter( dap_events_socket_t * a_es_input, dap_proc_queue_callback_t a_callback, void * a_callback_arg)
{ {
dap_proc_queue_msg_t * l_msg = DAP_NEW_Z(dap_proc_queue_msg_t); if (!l_msg) return; dap_proc_queue_msg_t * l_msg = DAP_NEW_Z(dap_proc_queue_msg_t);
if (!l_msg)
return -ENOMEM;
l_msg->callback = a_callback; l_msg->callback = a_callback;
l_msg->callback_arg = a_callback_arg; l_msg->callback_arg = a_callback_arg;
//log_it( L_DEBUG, "Sent inter callback %p/%p to queue input", l_msg->callback,l_msg->callback_arg);
dap_events_socket_queue_ptr_send_to_input( a_es_input , l_msg ); return dap_events_socket_queue_ptr_send_to_input( a_es_input , l_msg );
} }
...@@ -45,7 +45,7 @@ typedef struct dap_proc_queue{ ...@@ -45,7 +45,7 @@ typedef struct dap_proc_queue{
dap_proc_queue_t * dap_proc_queue_create(dap_proc_thread_t * a_thread); dap_proc_queue_t * dap_proc_queue_create(dap_proc_thread_t * a_thread);
void dap_proc_queue_delete(dap_proc_queue_t * a_queue); int dap_proc_queue_delete(dap_proc_queue_t * a_queue);
void dap_proc_queue_add_callback(dap_worker_t * a_worker, dap_proc_queue_callback_t a_callback, void * a_callback_arg); int dap_proc_queue_add_callback(dap_worker_t * a_worker, dap_proc_queue_callback_t a_callback, void * a_callback_arg);
void dap_proc_queue_add_callback_inter( dap_events_socket_t * a_es_input, dap_proc_queue_callback_t a_callback, void * a_callback_arg); int dap_proc_queue_add_callback_inter( dap_events_socket_t * a_es_input, dap_proc_queue_callback_t a_callback, void * a_callback_arg);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment