Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revised patch for byterun/io.{c,h}: channel close performance problem #3728

Closed
vicuna opened this issue Jul 17, 2005 · 1 comment
Closed
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 17, 2005

Original bug ID: 3728
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

The previous patch I submitted wasn't quite clean -- it ifdef-ed in the
original code. Here is a better patch.

[again, for version 3.08.3]


--- io.c.1 2004-01-08 17:28:48.000000000 -0500
+++ io.c 2005-07-17 22:09:42.000000000 -0400
@@ -15,6 +15,7 @@

/* Buffered input/output. */

+#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -70,6 +71,9 @@
channel->old_revealed = 0;
channel->refcount = 0;
channel->next = caml_all_opened_channels;

  • channel->prev = NULL;
  • if (NULL != caml_all_opened_channels)
  • caml_all_opened_channels->prev = channel;
    caml_all_opened_channels = channel;
    return channel;
    }
    @@ -85,12 +89,16 @@

static void unlink_channel(struct channel *channel)
{

  • struct channel ** cp = &caml_all_opened_channels;
  • Assert (caml_all_opened_channels);
  • while (*cp != channel && *cp != NULL)
  • cp = &(*cp)->next;
  • if (*cp != NULL)
  • *cp = (*cp)->next;
  • if (NULL == channel->prev) {
  • Assert (channel == caml_all_opened_channels);
  • caml_all_opened_channels = caml_all_opened_channels->next;
  • if (caml_all_opened_channels) caml_all_opened_channels->prev = NULL;
  • } else {
  • channel->prev->next = channel->next;
  • if (channel->next) channel->next->prev = channel->prev;
  • }
    }

CAMLexport void caml_close_channel(struct channel channel)
--- io.h.1 2004-01-01 11:42:36.000000000 -0500
+++ io.h 2005-07-15 13:24:35.000000000 -0400
@@ -40,6 +40,7 @@
char * max; /
Logical end of the buffer (for input) /
void * mutex; /
Placeholder for mutex (for systhreads) /
struct channel * next; /
Linear chaining of channels (flush_all) */

  • struct channel * prev; /* Linear chaining of channels (flush_all) /
    int revealed; /
    For Cash only /
    int old_revealed; /
    For Cash only /
    int refcount; /
    For flush_all and for Cash */


@vicuna
Copy link
Author

vicuna commented Jul 21, 2005

Comment author: administrator

see also #3727

@vicuna vicuna closed this as completed Sep 24, 2005
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant