typedef void (*Main_Loop_Child_Dead_Cb)(int pid, int status); /* void* for compat? */
typedef void (*Slave_Dead_Cb)(Slave *slave, void *data);
typedef void (*Slave_Read_Cb)(Slave *slave, Slave_Command cmd, void *msg, void *data);
-typedef void *(*Slave_Thread_Cb)(Slave_Thread_Data *sd, Slave_Command cmd, const void *cmddata, void *userdata);
+typedef void *(*Slave_Thread_Cb)(Slave_Thread_Data *sd, Slave_Command *cmd, const void *cmddata, void *userdata);
typedef void (*File_Change_Cb)(const char *path, Eina_Bool deleted, void *data);
void cserve2_client_accept(int fd);
void cserve2_font_init(void);
void cserve2_font_shutdown(void);
-void *cserve2_font_slave_cb(Slave_Thread_Data *sd, Slave_Command cmd, const void *cmddata, void *data);
+void *cserve2_font_slave_cb(Slave_Thread_Data *sd, Slave_Command *cmd, const void *cmddata, void *data);
#endif /* _EVAS_CSERVE2_H */
typedef struct _Font_Info Font_Info;
typedef struct _Font_Source_Info Font_Source_Info;
+static void *
+_font_slave_error_send(Error_Type error)
+{
+ Error_Type *e = calloc(1, sizeof(*e));
+ *e = error;
+
+ return e;
+}
+
static Font_Source_Info *
_font_slave_source_load(const char *file)
{
error = FT_Set_Pixel_Sizes(fsi->face, chosen_width, fi->real_size);
if (error)
- ERR("Could not choose the font size.");
+ {
+ ERR("Could not choose the font size for font: '%s'.", msg->name);
+ FT_Done_Size(fi->size);
+ free(fi);
+ return NULL;
+ }
}
fi->max_h = 0;
// FIXME: Return correct error message
if (!fsi)
- return NULL;
+ {
+ ERR("Could not load font source: '%s'", msg->file);
+ return NULL;
+ }
fi = _font_slave_int_load(msg, fsi);
+ if (!fi)
+ {
+ FT_Done_Face(fsi->face);
+ free(fsi);
+ return NULL;
+ }
response = calloc(1, sizeof(*response));
response->ftdata1 = fsi;
}
void *
-cserve2_font_slave_cb(Slave_Thread_Data *sd __UNUSED__, Slave_Command cmd, const void *cmddata, void *data)
+cserve2_font_slave_cb(Slave_Thread_Data *sd __UNUSED__, Slave_Command *cmd, const void *cmddata, void *data)
{
void *response = NULL;
- switch (cmd)
+ switch (*cmd)
{
case FONT_LOAD:
- _font_slave_load(cmddata, data);
+ response = _font_slave_load(cmddata, data);
break;
case FONT_GLYPHS_LOAD:
// command for FONT_GLYPHS_LOAD
break;
default:
- ERR("Invalid command for font slave: %d", cmd);
+ ERR("Invalid command for font slave: %d", *cmd);
+ *cmd = ERROR;
+ return _font_slave_error_send(CSERVE2_INVALID_COMMAND);
+ }
+
+ if (!response)
+ {
+ *cmd = ERROR;
+ return _font_slave_error_send(CSERVE2_GENERIC);
}
return response;
}
static void
-_slave_read_cb(Slave *s __UNUSED__, Slave_Command cmd __UNUSED__, void *msg, void *data)
+_slave_read_cb(Slave *s __UNUSED__, Slave_Command cmd, void *msg, void *data)
{
Slave_Worker *sw = data;
Font_Request *req = sw->data;
EINA_LIST_FREE(req->waiters, w)
{
- req->funcs->response(w->client, req->data, msg, w->rid);
+ if (cmd == ERROR)
+ {
+ Error_Type *err = msg;
+ req->funcs->error(w->client, req->data, *err, w->rid);
+ }
+ else
+ req->funcs->response(w->client, req->data, msg, w->rid);
free(w);
}
n);
continue;
}
- sd->cmdanswer = sd->cb(sd, cmd, sd->cmddata, sd->cb_data);
+ sd->cmdanswer = sd->cb(sd, &cmd, sd->cmddata, sd->cb_data);
write(sd->write_fd, &cmd, sizeof(cmd));
n = read(sd->read_fd, &cmd, sizeof(cmd));