forked from enlightenment/efl
evas/cserve2: Add valid flag on Image_Data and File_Data
Images and Files can be discovered by the client scanner before they are valid (aka. loaded or opened). We want clients to ignore all shared objects that are not ready yet, as they are in an undefined state (values and memory might be invalid).
This commit is contained in:
parent
a14e69e573
commit
9d2400af8b
|
@ -618,6 +618,7 @@ _open_request_response(Entry *entry, Slave_Msg_Image_Opened *resp, int *size)
|
||||||
fd->loader_data = cserve2_shared_string_add(ldata);
|
fd->loader_data = cserve2_shared_string_add(ldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fd->valid = EINA_TRUE;
|
||||||
return _image_opened_msg_create(fd, size);
|
return _image_opened_msg_create(fd, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,6 +832,7 @@ _load_request_response(Image_Entry *ientry,
|
||||||
idata = _image_data_find(ENTRYID(ientry));
|
idata = _image_data_find(ENTRYID(ientry));
|
||||||
if (!idata) return NULL;
|
if (!idata) return NULL;
|
||||||
|
|
||||||
|
idata->valid = EINA_TRUE;
|
||||||
_entry_load_finish(ASENTRY(ientry));
|
_entry_load_finish(ASENTRY(ientry));
|
||||||
ASENTRY(ientry)->request = NULL;
|
ASENTRY(ientry)->request = NULL;
|
||||||
|
|
||||||
|
@ -1529,6 +1531,7 @@ _image_entry_new(Client *client, int rid,
|
||||||
idata->opts.degree = opts->degree;
|
idata->opts.degree = opts->degree;
|
||||||
idata->opts.orientation = opts->orientation;
|
idata->opts.orientation = opts->orientation;
|
||||||
}
|
}
|
||||||
|
idata->valid = EINA_FALSE;
|
||||||
idata->file_id = ref->entry->id;
|
idata->file_id = ref->entry->id;
|
||||||
idata->refcount = 1;
|
idata->refcount = 1;
|
||||||
idata->id = image_id;
|
idata->id = image_id;
|
||||||
|
@ -2463,10 +2466,11 @@ cserve2_cache_file_open(Client *client, unsigned int client_file_id,
|
||||||
ERR("Could not create new file entry!");
|
ERR("Could not create new file entry!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd->id = file_id; // FIXME: write last (?)
|
fd->valid = EINA_FALSE;
|
||||||
fd->refcount = 1;
|
fd->refcount = 1;
|
||||||
fd->path = cserve2_shared_string_add(path);
|
fd->path = cserve2_shared_string_add(path);
|
||||||
fd->key = cserve2_shared_string_add(key);
|
fd->key = cserve2_shared_string_add(key);
|
||||||
|
fd->id = file_id;
|
||||||
|
|
||||||
fentry = calloc(1, sizeof(File_Entry));
|
fentry = calloc(1, sizeof(File_Entry));
|
||||||
ASENTRY(fentry)->type = CSERVE2_IMAGE_FILE;
|
ASENTRY(fentry)->type = CSERVE2_IMAGE_FILE;
|
||||||
|
|
|
@ -332,6 +332,7 @@ struct _File_Data {
|
||||||
int loop_hint;
|
int loop_hint;
|
||||||
Eina_Bool alpha : 1;
|
Eina_Bool alpha : 1;
|
||||||
Eina_Bool invalid : 1;
|
Eina_Bool invalid : 1;
|
||||||
|
Eina_Bool valid : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IMAGE_DATA_ARRAY_TAG ('I' | 'M' << 8 | 'A' << 16 | 'G' << 24)
|
#define IMAGE_DATA_ARRAY_TAG ('I' | 'M' << 8 | 'A' << 16 | 'G' << 24)
|
||||||
|
@ -343,6 +344,7 @@ struct _Image_Data {
|
||||||
Eina_Bool alpha_sparse : 1;
|
Eina_Bool alpha_sparse : 1;
|
||||||
Eina_Bool unused : 1;
|
Eina_Bool unused : 1;
|
||||||
Eina_Bool doload : 1;
|
Eina_Bool doload : 1;
|
||||||
|
Eina_Bool valid : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FONT_DATA_ARRAY_TAG ('F' | 'O' << 8 | 'N' << 16 | 'T' << 24)
|
#define FONT_DATA_ARRAY_TAG ('F' | 'O' << 8 | 'N' << 16 | 'T' << 24)
|
||||||
|
|
|
@ -440,6 +440,10 @@ _image_opened_cb(void *data, const void *msg_received, int size)
|
||||||
* -- jpeg
|
* -- jpeg
|
||||||
*/
|
*/
|
||||||
//DBG("Received OPENED for RID: %d [open_rid: %d]", answer->rid, ie->open_rid);
|
//DBG("Received OPENED for RID: %d [open_rid: %d]", answer->rid, ie->open_rid);
|
||||||
|
|
||||||
|
if (ie->server_id && !ie->open_rid)
|
||||||
|
return;
|
||||||
|
|
||||||
if (answer->rid != ie->open_rid)
|
if (answer->rid != ie->open_rid)
|
||||||
{
|
{
|
||||||
WRN("Message rid (%d) differs from expected rid (open_rid: %d)", answer->rid, ie->open_rid);
|
WRN("Message rid (%d) differs from expected rid (open_rid: %d)", answer->rid, ie->open_rid);
|
||||||
|
@ -536,6 +540,10 @@ _image_loaded_cb(void *data, const void *msg_received, int size)
|
||||||
Image_Entry *ie = data;
|
Image_Entry *ie = data;
|
||||||
|
|
||||||
//DBG("Received LOADED for RID: %d [load_rid: %d]", answer->rid, ie->load_rid);
|
//DBG("Received LOADED for RID: %d [load_rid: %d]", answer->rid, ie->load_rid);
|
||||||
|
|
||||||
|
if (!ie->load_rid)
|
||||||
|
return;
|
||||||
|
|
||||||
if (answer->rid != ie->load_rid)
|
if (answer->rid != ie->load_rid)
|
||||||
{
|
{
|
||||||
WRN("Message rid (%d) differs from expected rid (load_rid: %d)", answer->rid, ie->load_rid);
|
WRN("Message rid (%d) differs from expected rid (load_rid: %d)", answer->rid, ie->load_rid);
|
||||||
|
@ -926,7 +934,7 @@ evas_cserve2_image_load_wait(Image_Entry *ie)
|
||||||
|
|
||||||
#if USE_SHARED_INDEX
|
#if USE_SHARED_INDEX
|
||||||
fd = _shared_image_entry_file_data_find(ie);
|
fd = _shared_image_entry_file_data_find(ie);
|
||||||
if (fd)
|
if (fd && fd->valid)
|
||||||
{
|
{
|
||||||
INF("Bypassing socket wait (open_rid %d)", ie->open_rid);
|
INF("Bypassing socket wait (open_rid %d)", ie->open_rid);
|
||||||
ie->w = fd->w;
|
ie->w = fd->w;
|
||||||
|
@ -935,6 +943,7 @@ evas_cserve2_image_load_wait(Image_Entry *ie)
|
||||||
ie->animated.loop_hint = fd->loop_hint;
|
ie->animated.loop_hint = fd->loop_hint;
|
||||||
ie->animated.loop_count = fd->loop_count;
|
ie->animated.loop_count = fd->loop_count;
|
||||||
ie->animated.frame_count = fd->frame_count;
|
ie->animated.frame_count = fd->frame_count;
|
||||||
|
ie->server_id = fd->id;
|
||||||
ie->open_rid = 0;
|
ie->open_rid = 0;
|
||||||
return CSERVE2_NONE;
|
return CSERVE2_NONE;
|
||||||
}
|
}
|
||||||
|
@ -981,7 +990,7 @@ evas_cserve2_image_load_data_wait(Image_Entry *ie)
|
||||||
|
|
||||||
#if USE_SHARED_INDEX
|
#if USE_SHARED_INDEX
|
||||||
idata = _shared_image_entry_image_data_find(ie);
|
idata = _shared_image_entry_image_data_find(ie);
|
||||||
if (idata)
|
if (idata && idata->valid)
|
||||||
{
|
{
|
||||||
// FIXME: Ugly copy & paste from _loaded_handle
|
// FIXME: Ugly copy & paste from _loaded_handle
|
||||||
Data_Entry *dentry = ie->data2;
|
Data_Entry *dentry = ie->data2;
|
||||||
|
@ -2196,7 +2205,7 @@ _shared_image_entry_image_data_find(Image_Entry *ie)
|
||||||
eina_hash_find(_index.images.entries_by_hkey, ie->cache_key);
|
eina_hash_find(_index.images.entries_by_hkey, ie->cache_key);
|
||||||
if (idata)
|
if (idata)
|
||||||
{
|
{
|
||||||
ERR("Image found in shared index (by cache_key).");
|
DBG("Image found in shared index (by cache_key).");
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2254,6 +2263,12 @@ _shared_image_entry_image_data_find(Image_Entry *ie)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
found:
|
found:
|
||||||
|
if (!idata->valid)
|
||||||
|
{
|
||||||
|
DBG("Found image but it is not ready yet: %d", idata->id);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
shmpath = _shared_string_get(idata->shm_id);
|
shmpath = _shared_string_get(idata->shm_id);
|
||||||
if (!shmpath)
|
if (!shmpath)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue