struct wl_display *display;
struct wl_registry *registry;
struct wl_tdm *tdm;
+
+ struct {
+ int done;
+ char message[TDM_SERVER_REPLY_MSG_LEN];
+ char *m;
+ int len;
+ int *l;
+ } debug;
} tdm_monitor_info;
static tdm_monitor_info td_info;
-static int done;
static void
-_tdm_monitor_cb_debug_done(void *data, struct wl_tdm *wl_tdm, const char *message)
+_tdm_monitor_cb_debug_message(void *data, struct wl_tdm *wl_tdm, const char *message)
{
- printf("%s", message);
+ tdm_monitor_info *info = data;
+ TDM_SNPRINTF(info->debug.m, info->debug.l, "%s", message);
+}
- done = 1;
+static void
+_tdm_monitor_cb_debug_done(void *data, struct wl_tdm *wl_tdm)
+{
+ tdm_monitor_info *info = data;
+ info->debug.done = 1;
+ *(info->debug.m) = '\0';
+ printf("%s", info->debug.message);
}
static const struct wl_tdm_listener tdm_monitor_listener = {
+ _tdm_monitor_cb_debug_message,
_tdm_monitor_cb_debug_done,
};
for (i = 0; i < argc; i++)
TDM_SNPRINTF(str_buf, len_buf, "%s ", argv[i]);
- done = 0;
+ info->debug.done = 0;
+ info->debug.message[0] = '\0';
+ info->debug.len = sizeof(info->debug.message);
+ info->debug.m = info->debug.message;
+ info->debug.l = &info->debug.len;
wl_tdm_debug(info->tdm, options);
- while (!done && ret >= 0)
+ while (!info->debug.done && ret >= 0)
ret = wl_display_dispatch(info->display);
if (info->tdm)
TDM uses the wayland protocol to communicate between tdm client and tdm server.
</description>
- <event name="debug_done">
+ <event name="debug_message">
<arg name="message" type="string"/>
</event>
+ <event name="debug_done" />
+
<request name="debug">
<arg name="options" type="string" summary="debug options"/>
</request>
#endif
#define TDM_SERVER_REPLY_MSG_LEN 8192
+#define TDM_DEBUG_REPLY_MSG_LEN 2048
#undef EXTERN
#undef DEPRECATED
#define TDM_NOT_DEFINED_VALUE (-1)
#define TDM_FRONT_VALUE(n) (((n) > 0) ? (n) : TDM_NOT_DEFINED_VALUE)
+#define TDM_MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define TDM_MIN(x, y) (((x) < (y)) ? (x) : (y))
+
#define TDM_TIME(sec, usec) ((double)(sec) + ((double)(usec)) / 1000000.0)
#define TDM_TIME_SEC(time) ((unsigned int)(time))
#define TDM_TIME_USEC(time) (unsigned int)(((time) - (unsigned int)(time)) * 1000000.0)
tdm_private_server *private_server = wl_resource_get_user_data(resource);
tdm_private_loop *private_loop = private_server->private_loop;
char message[TDM_SERVER_REPLY_MSG_LEN];
- int size = sizeof(message);
+ char *m;
+ int len = sizeof(message), size;
uid_t uid;
wl_client_get_credentials(client, NULL, &uid, NULL);
if (uid != 0) {
- snprintf(message, size, "tdm-monitor: SHOULD be a superuser.\n");
+ snprintf(message, len, "tdm-monitor: SHOULD be a superuser.\n");
TDM_ERR("%s", message);
} else {
- tdm_monitor_server_command(private_loop->dpy, options, message, &size);
+ tdm_monitor_server_command(private_loop->dpy, options, message, &len);
}
- wl_tdm_send_debug_done(resource, message);
+ size = sizeof(message) - len;
+ m = message;
+
+ wl_client_flush(wl_resource_get_client(resource));
+
+ while (size > 0) {
+ char buffer[TDM_DEBUG_REPLY_MSG_LEN];
+ int copylen = TDM_MIN(size, sizeof(buffer) - 1);
+
+ strncpy(buffer, m, copylen);
+ m += copylen;
+ size -= copylen;
+
+ buffer[copylen] = '\0';
+
+ wl_tdm_send_debug_message(resource, buffer);
+ }
+
+ wl_tdm_send_debug_done(resource);
}
static void
pthread_mutex_lock(&valid_list_lock);
LIST_FOR_EACH_ENTRY(v, &valid_vblank_list, valid_link) {
- struct wl_client *client = wl_resource_get_client(v->resource);
const char *proc_name = NULL;
pid_t pid = 0;
- if (client) {
- wl_client_get_credentials(client, &pid, NULL, NULL);
- proc_name = tdm_server_get_client_name(pid);
+ if (v->resource) {
+ struct wl_client *client = wl_resource_get_client(v->resource);
+ if (client) {
+ wl_client_get_credentials(client, &pid, NULL, NULL);
+ proc_name = tdm_server_get_client_name(pid);
+ }
}
TDM_SNPRINTF(reply, len, "%-12s %u %u %d %u %s (pid: %u)\n",