2 * Copyright (C) 2008 Jan Schmidt <jan.schmidt@sun.com>
4 * gstpluginloader.c: GstPluginLoader helper for loading plugin files
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
28 #include <sys/types.h>
36 #include <gst/gst_private.h>
37 #include <gst/gstconfig.h>
39 #include <gst/gstpoll.h>
40 #include <gst/gstutils.h>
42 #include <gst/gstpluginloader.h>
43 #include <gst/gstregistrychunks.h>
44 #include <gst/gstregistrybinary.h>
46 /* IMPORTANT: Bump the version number if the plugin loader packet protocol
47 * changes. Changes in the binary registry format itself are handled by
48 * bumping the GST_MAGIC_BINARY_VERSION_STR
50 static const guint32 loader_protocol_version = 3;
52 #define GST_CAT_DEFAULT GST_CAT_PLUGIN_LOADING
54 static GstPluginLoader *plugin_loader_new (GstRegistry * registry);
55 static gboolean plugin_loader_free (GstPluginLoader * loader);
56 static gboolean plugin_loader_load (GstPluginLoader * loader,
57 const gchar * filename, off_t file_size, time_t file_mtime);
59 const GstPluginLoaderFuncs _priv_gst_plugin_loader_funcs = {
60 plugin_loader_new, plugin_loader_free, plugin_loader_load
63 typedef struct _PendingPluginEntry
71 struct _GstPluginLoader
73 GstRegistry *registry;
76 gboolean child_running;
82 gboolean got_plugin_details;
97 /* Head and tail of the pending plugins list. List of
98 PendingPluginEntry structs */
99 GList *pending_plugins;
100 GList *pending_plugins_tail;
103 #define PACKET_EXIT 1
104 #define PACKET_LOAD_PLUGIN 2
105 #define PACKET_SYNC 3
106 #define PACKET_PLUGIN_DETAILS 4
107 #define PACKET_VERSION 5
109 #define BUF_INIT_SIZE 512
110 #define BUF_GROW_EXTRA 512
111 #define BUF_MAX_SIZE (32 * 1024 * 1024)
113 #define HEADER_SIZE 12
114 /* 4 magic hex bytes to mark each packet */
115 #define HEADER_MAGIC 0xbefec0ae
116 #define ALIGNMENT (sizeof (void *))
118 static gboolean gst_plugin_loader_spawn (GstPluginLoader * loader);
119 static void put_packet (GstPluginLoader * loader, guint type, guint32 tag,
120 const guint8 * payload, guint32 payload_len);
121 static gboolean exchange_packets (GstPluginLoader * l);
122 static gboolean plugin_loader_replay_pending (GstPluginLoader * l);
123 static gboolean plugin_loader_load_and_sync (GstPluginLoader * l,
124 PendingPluginEntry * entry);
125 static void plugin_loader_create_blacklist_plugin (GstPluginLoader * l,
126 PendingPluginEntry * entry);
127 static void plugin_loader_cleanup_child (GstPluginLoader * loader);
128 static gboolean plugin_loader_sync_with_child (GstPluginLoader * l);
130 static GstPluginLoader *
131 plugin_loader_new (GstRegistry * registry)
133 GstPluginLoader *l = g_new0 (GstPluginLoader, 1);
136 l->registry = gst_object_ref (registry);
137 l->fdset = gst_poll_new (FALSE);
138 gst_poll_fd_init (&l->fd_w);
139 gst_poll_fd_init (&l->fd_r);
141 l->tx_buf_size = BUF_INIT_SIZE;
142 l->tx_buf = g_malloc (BUF_INIT_SIZE);
146 l->rx_buf_size = BUF_INIT_SIZE;
147 l->rx_buf = g_malloc (BUF_INIT_SIZE);
153 plugin_loader_free (GstPluginLoader * loader)
156 gboolean got_plugin_details;
158 fsync (loader->fd_w.fd);
160 if (loader->child_running) {
161 put_packet (loader, PACKET_EXIT, 0, NULL, 0);
163 /* Swap packets with the child until it exits cleanly */
164 while (!loader->rx_done) {
165 if (exchange_packets (loader) || loader->rx_done)
168 if (!plugin_loader_replay_pending (loader))
170 put_packet (loader, PACKET_EXIT, 0, NULL, 0);
173 plugin_loader_cleanup_child (loader);
175 close (loader->fd_w.fd);
176 close (loader->fd_r.fd);
179 gst_poll_free (loader->fdset);
181 g_free (loader->rx_buf);
182 g_free (loader->tx_buf);
184 if (loader->registry)
185 gst_object_unref (loader->registry);
187 got_plugin_details = loader->got_plugin_details;
189 /* Free any pending plugin entries */
190 cur = loader->pending_plugins;
192 PendingPluginEntry *entry = (PendingPluginEntry *) (cur->data);
193 g_free (entry->filename);
196 cur = g_list_delete_link (cur, cur);
201 return got_plugin_details;
205 plugin_loader_load (GstPluginLoader * loader, const gchar * filename,
206 off_t file_size, time_t file_mtime)
209 PendingPluginEntry *entry;
211 if (!gst_plugin_loader_spawn (loader))
214 /* Send a packet to the child requesting that it load the given file */
215 GST_LOG_OBJECT (loader->registry,
216 "Sending file %s to child. tag %u", filename, loader->next_tag);
218 entry = g_new (PendingPluginEntry, 1);
219 entry->tag = loader->next_tag++;
220 entry->filename = g_strdup (filename);
221 entry->file_size = file_size;
222 entry->file_mtime = file_mtime;
223 loader->pending_plugins_tail =
224 g_list_append (loader->pending_plugins_tail, entry);
226 if (loader->pending_plugins == NULL)
227 loader->pending_plugins = loader->pending_plugins_tail;
229 loader->pending_plugins_tail = g_list_next (loader->pending_plugins_tail);
231 len = strlen (filename);
232 put_packet (loader, PACKET_LOAD_PLUGIN, entry->tag,
233 (guint8 *) filename, len + 1);
235 if (!exchange_packets (loader)) {
236 if (!plugin_loader_replay_pending (loader))
244 plugin_loader_replay_pending (GstPluginLoader * l)
249 if (!gst_plugin_loader_spawn (l))
252 /* Load each plugin one by one synchronously until we find the
254 while ((cur = l->pending_plugins)) {
255 PendingPluginEntry *entry = (PendingPluginEntry *) (cur->data);
257 if (!plugin_loader_load_and_sync (l, entry)) {
258 /* Create dummy plugin entry to block re-scanning this file */
259 GST_ERROR ("Plugin file %s failed to load. Blacklisting",
261 plugin_loader_create_blacklist_plugin (l, entry);
262 l->got_plugin_details = TRUE;
263 /* Now remove this crashy plugin from the head of the list */
264 l->pending_plugins = g_list_delete_link (cur, cur);
265 if (l->pending_plugins == NULL)
266 l->pending_plugins_tail = NULL;
267 if (!gst_plugin_loader_spawn (l))
273 /* We exited after finding the crashing one. If there's any more pending,
274 * dispatch them post-haste, but don't wait */
275 for (cur = l->pending_plugins; cur != NULL; cur = next) {
276 PendingPluginEntry *entry = (PendingPluginEntry *) (cur->data);
278 next = g_list_next (cur);
280 put_packet (l, PACKET_LOAD_PLUGIN, entry->tag,
281 (guint8 *) entry->filename, strlen (entry->filename) + 1);
283 /* This might invalidate cur, which is why we grabbed 'next' above */
284 if (!exchange_packets (l))
292 plugin_loader_sync_with_child (GstPluginLoader * l)
294 put_packet (l, PACKET_SYNC, 0, NULL, 0);
296 l->rx_got_sync = FALSE;
297 while (!l->rx_got_sync) {
298 if (!exchange_packets (l))
305 plugin_loader_load_and_sync (GstPluginLoader * l, PendingPluginEntry * entry)
309 GST_DEBUG_OBJECT (l->registry, "Synchronously loading plugin file %s",
312 len = strlen (entry->filename);
313 put_packet (l, PACKET_LOAD_PLUGIN, entry->tag,
314 (guint8 *) entry->filename, len + 1);
316 return plugin_loader_sync_with_child (l);
320 plugin_loader_create_blacklist_plugin (GstPluginLoader * l,
321 PendingPluginEntry * entry)
323 GstPlugin *plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
325 plugin->filename = g_strdup (entry->filename);
326 plugin->file_mtime = entry->file_mtime;
327 plugin->file_size = entry->file_size;
328 plugin->flags |= GST_PLUGIN_FLAG_BLACKLISTED;
330 plugin->basename = g_path_get_basename (plugin->filename);
331 plugin->desc.name = g_intern_string (plugin->basename);
332 plugin->desc.description = g_strdup_printf ("Plugin for blacklisted file");
333 plugin->desc.version = g_intern_string ("0.0.0");
334 plugin->desc.license = g_intern_string ("BLACKLIST");
335 plugin->desc.source = plugin->desc.license;
336 plugin->desc.package = plugin->desc.license;
337 plugin->desc.origin = plugin->desc.license;
339 GST_DEBUG ("Adding blacklist plugin '%s'", plugin->desc.name);
340 gst_registry_add_plugin (l->registry, plugin);
344 gst_plugin_loader_try_helper (GstPluginLoader * loader, gchar * location)
346 char *argv[] = { location, "-l", NULL };
348 GST_LOG ("Trying to spawn plugin-scanner helper at %s", location);
349 if (!g_spawn_async_with_pipes (NULL, argv, NULL,
350 G_SPAWN_DO_NOT_REAP_CHILD /* | G_SPAWN_STDERR_TO_DEV_NULL */ ,
351 NULL, NULL, &loader->child_pid, &loader->fd_w.fd, &loader->fd_r.fd,
355 gst_poll_add_fd (loader->fdset, &loader->fd_w);
356 gst_poll_add_fd (loader->fdset, &loader->fd_r);
358 gst_poll_fd_ctl_read (loader->fdset, &loader->fd_r, TRUE);
360 loader->tx_buf_write = loader->tx_buf_read = 0;
362 put_packet (loader, PACKET_VERSION, 0, NULL, 0);
363 if (!plugin_loader_sync_with_child (loader))
366 loader->child_running = TRUE;
372 gst_plugin_loader_spawn (GstPluginLoader * loader)
377 if (loader->child_running)
380 /* Find the plugin-scanner, first try installed then by env-var */
381 helper_bin = g_strdup (GST_PLUGIN_SCANNER_INSTALLED);
382 res = gst_plugin_loader_try_helper (loader, helper_bin);
386 /* Try the GST_PLUGIN_SCANNER env var */
387 const gchar *env = g_getenv ("GST_PLUGIN_SCANNER");
389 GST_LOG ("Installed plugin scanner failed. "
390 "Trying GST_PLUGIN_SCANNER env var: %s", env);
391 helper_bin = g_strdup (env);
392 res = gst_plugin_loader_try_helper (loader, helper_bin);
395 GST_LOG ("Installed plugin scanner failed and "
396 "GST_PLUGIN_SCANNER env var not set. No plugin-scanner available");
400 return loader->child_running;
404 plugin_loader_cleanup_child (GstPluginLoader * l)
406 if (!l->child_running || l->is_child)
409 gst_poll_remove_fd (l->fdset, &l->fd_w);
410 gst_poll_remove_fd (l->fdset, &l->fd_r);
416 GST_LOG ("waiting for child process to exit");
417 waitpid (l->child_pid, NULL, 0);
419 g_warning ("FIXME: Implement child process shutdown for Win32");
421 g_spawn_close_pid (l->child_pid);
423 l->child_running = FALSE;
427 _gst_plugin_loader_client_run ()
432 l = plugin_loader_new (NULL);
436 /* On entry, the inward pipe is STDIN, and outward is STDOUT.
437 * Dup those somewhere better so that plugins printing things
438 * won't interfere with anything */
440 dup_fd = dup (0); /* STDIN */
442 GST_ERROR ("Failed to start. Could no dup STDIN, errno %d", errno);
448 dup_fd = dup (1); /* STDOUT */
450 GST_ERROR ("Failed to start. Could no dup STDOUT, errno %d", errno);
456 /* Dup stderr down to stdout so things that plugins print are visible,
457 * but don't care if it fails */
460 /* FIXME: Use DuplicateHandle and friends on win32 */
461 l->fd_w.fd = 1; /* STDOUT */
462 l->fd_r.fd = 0; /* STDIN */
465 gst_poll_add_fd (l->fdset, &l->fd_w);
466 gst_poll_add_fd (l->fdset, &l->fd_r);
467 gst_poll_fd_ctl_read (l->fdset, &l->fd_r, TRUE);
471 GST_DEBUG ("Plugin scanner child running. Waiting for instructions");
473 /* Loop, listening for incoming packets on the fd and writing responses */
474 while (!l->rx_done && exchange_packets (l));
476 plugin_loader_free (l);
482 put_packet (GstPluginLoader * l, guint type, guint32 tag,
483 const guint8 * payload, guint32 payload_len)
486 guint len = payload_len + HEADER_SIZE;
488 if (l->tx_buf_write + len >= l->tx_buf_size) {
489 l->tx_buf_size = l->tx_buf_write + len + BUF_GROW_EXTRA;
490 l->tx_buf = g_realloc (l->tx_buf, l->tx_buf_size);
493 out = l->tx_buf + l->tx_buf_write;
495 /* one byte packet type */
497 /* 3 byte packet tag number */
498 GST_WRITE_UINT24_BE (out + 1, tag);
499 /* 4 bytes packet length */
500 GST_WRITE_UINT32_BE (out + 4, payload_len);
502 memcpy (out + HEADER_SIZE, payload, payload_len);
503 /* Write magic into the header */
504 GST_WRITE_UINT32_BE (out + 8, HEADER_MAGIC);
506 l->tx_buf_write += len;
507 gst_poll_fd_ctl_write (l->fdset, &l->fd_w, TRUE);
511 put_chunk (GstPluginLoader * l, GstRegistryChunk * chunk, guint * pos)
517 /* Might need to align the chunk */
518 if (chunk->align && ((*pos) % ALIGNMENT) != 0)
519 padsize = ALIGNMENT - ((*pos) % ALIGNMENT);
521 len = padsize + chunk->size;
523 if (l->tx_buf_write + len >= l->tx_buf_size) {
524 l->tx_buf_size = l->tx_buf_write + len + BUF_GROW_EXTRA;
525 l->tx_buf = g_realloc (l->tx_buf, l->tx_buf_size);
528 out = l->tx_buf + l->tx_buf_write;
529 /* Clear the padding */
531 memset (out, 0, padsize);
532 memcpy (out + padsize, chunk->data, chunk->size);
534 l->tx_buf_write += len;
537 gst_poll_fd_ctl_write (l->fdset, &l->fd_w, TRUE);
541 write_one (GstPluginLoader * l)
544 guint32 to_write, magic;
547 if (l->tx_buf_read + HEADER_SIZE > l->tx_buf_write)
550 out = l->tx_buf + l->tx_buf_read;
552 magic = GST_READ_UINT32_BE (out + 8);
553 if (magic != HEADER_MAGIC) {
554 GST_ERROR ("Packet magic number is missing. Memory corruption detected");
555 goto fail_and_cleanup;
558 to_write = GST_READ_UINT32_BE (out + 4) + HEADER_SIZE;
559 /* Check that the magic is intact, and the size is sensible */
560 if (to_write > l->tx_buf_size) {
561 GST_ERROR ("Indicated packet size is too large. Corruption detected");
562 goto fail_and_cleanup;
565 l->tx_buf_read += to_write;
567 GST_LOG ("Writing packet of size %d bytes to fd %d", to_write, l->fd_w.fd);
570 res = write (l->fd_w.fd, out, to_write);
575 } while (to_write > 0 && res < 0 && (errno == EAGAIN || errno == EINTR));
577 /* Failed to write -> child died */
578 goto fail_and_cleanup;
581 if (l->tx_buf_read == l->tx_buf_write) {
582 gst_poll_fd_ctl_write (l->fdset, &l->fd_w, FALSE);
583 l->tx_buf_read = l->tx_buf_write = 0;
589 plugin_loader_cleanup_child (l);
594 do_plugin_load (GstPluginLoader * l, const gchar * filename, guint tag)
596 GstPlugin *newplugin;
597 GList *chunks = NULL;
599 GST_DEBUG ("Plugin scanner loading file %s. tag %u\n", filename, tag);
601 #if 0 /* Test code - crash based on filename */
602 if (strstr (filename, "coreelements") == NULL) {
603 g_printerr ("Crashing on file %s\n", filename);
604 g_printerr ("%d", *(gint *) (NULL));
609 newplugin = gst_plugin_load_file ((gchar *) filename, NULL);
614 /* Now serialise the plugin details and send */
615 if (!_priv_gst_registry_chunks_save_plugin (&chunks,
616 gst_registry_get_default (), newplugin))
619 /* Store where the header is, write an empty one, then write
620 * all the payload chunks, then fix up the header size */
621 hdr_pos = l->tx_buf_write;
622 offset = HEADER_SIZE;
623 put_packet (l, PACKET_PLUGIN_DETAILS, tag, NULL, 0);
627 for (walk = chunks; walk; walk = g_list_next (walk)) {
628 GstRegistryChunk *cur = walk->data;
629 put_chunk (l, cur, &offset);
631 if (!(cur->flags & GST_REGISTRY_CHUNK_FLAG_CONST))
636 g_list_free (chunks);
638 /* Store the size of the written payload */
639 GST_WRITE_UINT32_BE (l->tx_buf + hdr_pos + 4, offset - HEADER_SIZE);
641 #if 0 /* Test code - corrupt the tx buffer based on filename */
642 if (strstr (filename, "sink") != NULL) {
644 g_printerr ("Corrupting tx buf on file %s\n", filename);
645 fd = open ("/dev/urandom", O_RDONLY);
646 res = read (fd, l->tx_buf, l->tx_buf_size);
651 gst_object_unref (newplugin);
653 put_packet (l, PACKET_PLUGIN_DETAILS, tag, NULL, 0);
658 put_packet (l, PACKET_PLUGIN_DETAILS, tag, NULL, 0);
661 for (walk = chunks; walk; walk = g_list_next (walk)) {
662 GstRegistryChunk *cur = walk->data;
664 if (!(cur->flags & GST_REGISTRY_CHUNK_FLAG_CONST))
669 g_list_free (chunks);
676 check_protocol_version (GstPluginLoader * l, guint8 * payload,
680 guint8 *binary_reg_ver;
682 if (payload_len < sizeof (guint32) + GST_MAGIC_BINARY_VERSION_LEN)
685 got_version = GST_READ_UINT32_BE (payload);
686 GST_LOG ("Got VERSION %u from child. Ours is %u", got_version,
687 loader_protocol_version);
688 if (got_version != loader_protocol_version)
691 binary_reg_ver = payload + sizeof (guint32);
692 if (strcmp ((gchar *) binary_reg_ver, GST_MAGIC_BINARY_VERSION_STR)) {
693 GST_LOG ("Binary chunk format of child is different. Ours: %s, child %s\n",
694 GST_MAGIC_BINARY_VERSION_STR, binary_reg_ver);
702 handle_rx_packet (GstPluginLoader * l,
703 guint pack_type, guint32 tag, guint8 * payload, guint payload_len)
709 gst_poll_fd_ctl_read (l->fdset, &l->fd_r, FALSE);
711 /* Respond, then we keep looping until the parent closes the fd */
712 put_packet (l, PACKET_EXIT, 0, NULL, 0);
714 l->rx_done = TRUE; /* All done reading from child */
717 case PACKET_LOAD_PLUGIN:{
721 /* Payload is the filename to load */
722 res = do_plugin_load (l, (gchar *) payload, tag);
726 case PACKET_PLUGIN_DETAILS:{
727 gchar *tmp = (gchar *) payload;
728 PendingPluginEntry *entry = NULL;
731 GST_DEBUG_OBJECT (l->registry,
732 "Received plugin details from child w/ tag %u. %d bytes info",
735 /* Assume that tagged details come back in the order
736 * we requested, and delete anything before this one */
737 cur = l->pending_plugins;
739 PendingPluginEntry *e = (PendingPluginEntry *) (cur->data);
744 cur = g_list_delete_link (cur, cur);
750 g_free (e->filename);
754 l->pending_plugins = cur;
756 l->pending_plugins_tail = NULL;
758 if (payload_len > 0) {
759 GstPlugin *newplugin;
760 _priv_gst_registry_chunks_load_plugin (l->registry, &tmp,
761 tmp + payload_len, &newplugin);
762 newplugin->flags &= ~GST_PLUGIN_FLAG_CACHED;
763 GST_LOG_OBJECT (l->registry,
764 "marking plugin %p as registered as %s", newplugin,
765 newplugin->filename);
766 newplugin->registered = TRUE;
768 /* We got a set of plugin details - remember it for later */
769 l->got_plugin_details = TRUE;
770 } else if (entry != NULL) {
771 /* Create a blacklist entry for this file to prevent scanning every time */
772 plugin_loader_create_blacklist_plugin (l, entry);
773 l->got_plugin_details = TRUE;
777 g_free (entry->filename);
785 /* Respond with our reply - also a sync */
786 put_packet (l, PACKET_SYNC, tag, NULL, 0);
787 GST_LOG ("Got SYNC in child - replying");
789 l->rx_got_sync = TRUE;
793 /* Respond with our reply - a version packet, with the version */
794 const gint version_len =
795 sizeof (guint32) + GST_MAGIC_BINARY_VERSION_LEN;
796 guint8 version_info[sizeof (guint32) + GST_MAGIC_BINARY_VERSION_LEN];
797 memset (version_info, 0, version_len);
798 GST_WRITE_UINT32_BE (version_info, loader_protocol_version);
799 memcpy (version_info + sizeof (guint32), GST_MAGIC_BINARY_VERSION_STR,
800 strlen (GST_MAGIC_BINARY_VERSION_STR));
801 put_packet (l, PACKET_VERSION, tag, version_info, version_len);
802 GST_LOG ("Got VERSION in child - replying %u", loader_protocol_version);
804 res = check_protocol_version (l, payload, payload_len);
808 return FALSE; /* Invalid packet -> something is wrong */
815 read_one (GstPluginLoader * l)
818 guint32 to_read, packet_len, tag;
822 to_read = HEADER_SIZE;
825 res = read (l->fd_r.fd, in, to_read);
830 } while (to_read > 0 && res < 0 && (errno == EAGAIN || errno == EINTR));
833 GST_LOG ("Failed reading packet header");
837 magic = GST_READ_UINT32_BE (l->rx_buf + 8);
838 if (magic != HEADER_MAGIC) {
840 ("Invalid packet (bad magic number) received from plugin scanner subprocess");
844 packet_len = GST_READ_UINT32_BE (l->rx_buf + 4);
845 if (packet_len + HEADER_SIZE > BUF_MAX_SIZE) {
847 ("Received excessively large packet for plugin scanner subprocess");
851 if (packet_len + HEADER_SIZE >= l->rx_buf_size) {
852 l->rx_buf_size = packet_len + HEADER_SIZE + BUF_GROW_EXTRA;
853 l->rx_buf = g_realloc (l->rx_buf, l->rx_buf_size);
856 in = l->rx_buf + HEADER_SIZE;
857 to_read = packet_len;
859 res = read (l->fd_r.fd, in, to_read);
864 } while (to_read > 0 && res < 0 && (errno == EAGAIN || errno == EINTR));
867 GST_ERROR ("Packet payload read failed");
871 tag = GST_READ_UINT24_BE (l->rx_buf + 1);
873 return handle_rx_packet (l, l->rx_buf[0], tag,
874 l->rx_buf + HEADER_SIZE, packet_len);
878 exchange_packets (GstPluginLoader * l)
882 /* Wait for activity on our FDs */
885 res = gst_poll_wait (l->fdset, GST_SECOND);
886 } while (res == -1 && (errno == EINTR || errno == EAGAIN));
891 GST_LOG ("Poll res = %d. %d bytes pending for write", res,
892 l->tx_buf_write - l->tx_buf_read);
895 if (gst_poll_fd_has_error (l->fdset, &l->fd_r) ||
896 gst_poll_fd_has_closed (l->fdset, &l->fd_r)) {
897 GST_LOG ("read fd %d closed/errored", l->fd_r.fd);
898 plugin_loader_cleanup_child (l);
902 if (gst_poll_fd_can_read (l->fdset, &l->fd_r)) {
908 if (l->tx_buf_read < l->tx_buf_write) {
909 if (gst_poll_fd_has_error (l->fdset, &l->fd_w) ||
910 gst_poll_fd_has_closed (l->fdset, &l->fd_r)) {
911 GST_ERROR ("write fd %d closed/errored", l->fd_w.fd);
912 plugin_loader_cleanup_child (l);
915 if (gst_poll_fd_can_write (l->fdset, &l->fd_w)) {
920 } while (l->tx_buf_read < l->tx_buf_write);