Fix segfaults in ALL_IN_ONE mode

This commit is contained in:
Kirill Zhumarin 2019-01-09 17:22:52 +02:00 committed by GitHub
parent d021b90751
commit 1dedb64439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -352,14 +352,15 @@ mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t** mythre
entry->queue = queue;
for(size_t i = 0; i < list_size; i++) {
if(mythread_list[i]) {
if(mythread_list[i]->type == MyTHREAD_TYPE_BATCH)
mythread_queue_list_entry_make_batch(mythread_list[i], entry);
else
mythread_queue_list_entry_make_stream(mythread_list[i], entry);
if(mythread_list[i])
mythread_suspend(mythread_list[i]);
}
}
if(queue_list->first) {
queue_list->last->next = entry;
@ -453,11 +454,11 @@ bool mythread_queue_list_entry_see_for_done(mythread_queue_list_entry_t *entry)
void mythread_queue_list_entry_make_batch(mythread_t* mythread, mythread_queue_list_entry_t* entry)
{
if(entry == NULL)
if(entry == NULL || mythread == NULL)
return;
size_t i = 0;
for(size_t from = mythread->id_increase; from <= mythread->entries_length; from++) {
for(size_t from = mythread->id_increase; from < mythread->entries_length; from++) {
entry->thread_param[from].use = i;
i++;
}
@ -465,10 +466,10 @@ void mythread_queue_list_entry_make_batch(mythread_t* mythread, mythread_queue_l
void mythread_queue_list_entry_make_stream(mythread_t* mythread, mythread_queue_list_entry_t* entry)
{
if(entry == NULL)
if(entry == NULL || mythread == NULL)
return;
for(size_t from = mythread->id_increase; from <= mythread->entries_length; from++) {
for(size_t from = mythread->id_increase; from < mythread->entries_length; from++) {
entry->thread_param[from].use = 0;
}
}