summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-12-25 13:00:38 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-12-26 17:49:34 +0000
commitde2ec0559b01dba7919503955cc47c1c5fcd0f97 (patch)
treec752f1581c997961449b07f47b2a2d4449a30e9f /src/lib/eina
parentc3f37111ff6455a2a89cb760c76fb9cb08a7e202 (diff)
fix crashes created by "make efl_loop_promise_new a function"
commit 9b5155c9f135f9ef450a817979f5884352b2d4c0 brought about crashes - specifically that i saw in terminology because it actually uses eina_promise_data_set() and the new efl_loop_promise_new basically took over ownership of that data, but if anyone used eina_promise_data_set() the data ptr used by this new code would bwe overwritten, causing segfauls when terminology loses selection ownership. for days i had mysterious crashes of terminology until i narrowed it down to the above, so if you have too, then this will fix it. what this does is create a data set intercept function callback that for now is only for use inside efl to everride data sets so they set data inside the new struct that tracks data. i also had to add and intercept for eina_promise_data_free_cb_set() as this in theory could also ber a similar problem. so perhaps the idea/design of efl_loop_promise_new() is not right and this kind of thgn has to be internal to eina promise... this means eina promise and loops are much more tied together.
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_promise.c36
-rw-r--r--src/lib/eina/eina_promise.h42
2 files changed, 76 insertions, 2 deletions
diff --git a/src/lib/eina/eina_promise.c b/src/lib/eina/eina_promise.c
index c239ba6261..aa5ced8ab2 100644
--- a/src/lib/eina/eina_promise.c
+++ b/src/lib/eina/eina_promise.c
@@ -103,6 +103,8 @@ struct _Eina_Promise {
103 Eina_Future *future; 103 Eina_Future *future;
104 Eina_Future_Scheduler *scheduler; 104 Eina_Future_Scheduler *scheduler;
105 Eina_Promise_Cancel_Cb cancel; 105 Eina_Promise_Cancel_Cb cancel;
106 Eina_Promise_Data_Set_Cb data_set_cb;
107 Eina_Promise_Data_Free_Cb_Set_Cb data_free_cb_set_cb;
106 Eina_Free_Cb free_cb; 108 Eina_Free_Cb free_cb;
107 const void *data; 109 const void *data;
108}; 110};
@@ -1116,7 +1118,14 @@ eina_promise_data_set(Eina_Promise *p,
1116 void *data) 1118 void *data)
1117{ 1119{
1118 EINA_SAFETY_ON_NULL_RETURN(p); 1120 EINA_SAFETY_ON_NULL_RETURN(p);
1119 p->data = data; 1121 if (p->data_set_cb)
1122 {
1123 Eina_Promise_Data_Set_Cb cb = p->data_set_cb;
1124 p->data_set_cb = NULL;
1125 cb(p, data);
1126 p->data_set_cb = cb;
1127 }
1128 else p->data = data;
1120} 1129}
1121 1130
1122EAPI void 1131EAPI void
@@ -1124,7 +1133,30 @@ eina_promise_data_free_cb_set(Eina_Promise *p,
1124 Eina_Free_Cb free_cb) 1133 Eina_Free_Cb free_cb)
1125{ 1134{
1126 EINA_SAFETY_ON_NULL_RETURN(p); 1135 EINA_SAFETY_ON_NULL_RETURN(p);
1127 p->free_cb = free_cb; 1136 if (p->data_free_cb_set_cb)
1137 {
1138 Eina_Promise_Data_Free_Cb_Set_Cb cb = p->data_free_cb_set_cb;
1139 p->data_free_cb_set_cb = NULL;
1140 cb(p, free_cb);
1141 p->data_free_cb_set_cb = cb;
1142 }
1143 else p->free_cb = free_cb;
1144}
1145
1146EAPI void
1147eina_promise_data_set_cb_set(Eina_Promise *p,
1148 Eina_Promise_Data_Set_Cb data_set_cb)
1149{
1150 EINA_SAFETY_ON_NULL_RETURN(p);
1151 p->data_set_cb = data_set_cb;
1152}
1153
1154EAPI void
1155eina_promise_data_free_cb_set_cb_set(Eina_Promise *p,
1156 Eina_Promise_Data_Free_Cb_Set_Cb data_free_cb_set_cb)
1157{
1158 EINA_SAFETY_ON_NULL_RETURN(p);
1159 p->data_free_cb_set_cb = data_free_cb_set_cb;
1128} 1160}
1129 1161
1130static Eina_Value 1162static Eina_Value
diff --git a/src/lib/eina/eina_promise.h b/src/lib/eina/eina_promise.h
index 1896260dba..060d8dccf8 100644
--- a/src/lib/eina/eina_promise.h
+++ b/src/lib/eina/eina_promise.h
@@ -187,6 +187,26 @@ struct _Eina_Future_Scheduler {
187 */ 187 */
188typedef void (*Eina_Promise_Cancel_Cb) (void *data, const Eina_Promise *dead_promise); 188typedef void (*Eina_Promise_Cancel_Cb) (void *data, const Eina_Promise *dead_promise);
189 189
190/*
191 * @typedef Eina_Promise_Data_Set_Cb Eina_Promise_Data_Set_Cb.
192 * @ingroup eina_promise
193 *
194 * A callback used to intercept eina_promise_data_set().
195 *
196 * Used internally by EFL - please do not use.
197 */
198typedef void (*Eina_Promise_Data_Set_Cb) (Eina_Promise *p, void *data);
199
200/*
201 * @typedef Eina_Promise_Data_Free_Cb_Set_Cb Eina_Promise_Data_Free_Cb_Set_Cb.
202 * @ingroup eina_promise
203 *
204 * A callback used to intercept eina_promise_data_set_cb_set().
205 *
206 * Used internally by EFL - please do not use.
207 */
208typedef void (*Eina_Promise_Data_Free_Cb_Set_Cb) (Eina_Promise *p, Eina_Free_Cb free_cb);
209
190/** 210/**
191 * @typedef Eina_Future_Success_Cb Eina_Future_Success_Cb. 211 * @typedef Eina_Future_Success_Cb Eina_Future_Success_Cb.
192 * @ingroup eina_future 212 * @ingroup eina_future
@@ -637,6 +657,28 @@ EAPI void eina_promise_data_set(Eina_Promise *p, void *data) EINA_ARG_NONNULL(1)
637EAPI void eina_promise_data_free_cb_set(Eina_Promise *p, Eina_Free_Cb free_cb); 657EAPI void eina_promise_data_free_cb_set(Eina_Promise *p, Eina_Free_Cb free_cb);
638 658
639/** 659/**
660 * Sets a data set intercept function that can alter the behavior of
661 * eina_promise_data_set(). Please do not use this as it is only used
662 * internally inside EFL and may be used to slightly alter a promise
663 * behavior and if used on these promises may remove EFL's override
664 *
665 * @param[in] p The promise to set the data set callback on
666 * @param[in] data_set_cb The callabck to intercept the data set
667 */
668EAPI void eina_promise_data_set_cb_set(Eina_Promise *p, Eina_Promise_Data_Set_Cb data_set_cb);
669
670/**
671 * Sets a data free cb set intercept function that can alter the behavior of
672 * eina_promise_data_free_cb_set(). Please do not use this as it is only used
673 * internally inside EFL and may be used to slightly alter a promise
674 * behavior and if used on these promises may remove EFL's override
675 *
676 * @param[in] p The promise to set the data set callback on
677 * @param[in] data_free_cb_set_cb The callabck to intercept the data free cb set
678 */
679EAPI void eina_promise_data_free_cb_set_cb_set(Eina_Promise *p, Eina_Promise_Data_Free_Cb_Set_Cb data_free_cb_set_cb);
680
681/**
640 * Resolves a promise. 682 * Resolves a promise.
641 * 683 *
642 * This function schedules a resolve event in a 684 * This function schedules a resolve event in a