diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-11-24 22:17:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-11-24 22:17:15 +0000 |
commit | c015c83440507c1503c07d39740f13075efd926c (patch) | |
tree | 6131a6dcdd64ca175023a3929bf74444c9565b7d /src/stream | |
parent | ad16d03db236ff504ec7ed2cbd32c5a6653bc315 (diff) | |
download | gnunet-c015c83440507c1503c07d39740f13075efd926c.tar.gz gnunet-c015c83440507c1503c07d39740f13075efd926c.zip |
-ensure that either stream_api calls callbacks last or that we don't destroy a stream handle while it is in use below us on the stack
Diffstat (limited to 'src/stream')
-rw-r--r-- | src/stream/stream_api.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/stream/stream_api.c b/src/stream/stream_api.c index 46f7abb47..f9152749d 100644 --- a/src/stream/stream_api.c +++ b/src/stream/stream_api.c | |||
@@ -1917,13 +1917,16 @@ handle_receive_close (struct GNUNET_STREAM_Socket *socket, | |||
1917 | that that stream has been shutdown */ | 1917 | that that stream has been shutdown */ |
1918 | if (NULL != socket->write_handle) | 1918 | if (NULL != socket->write_handle) |
1919 | { | 1919 | { |
1920 | // FIXME: this breaks if 'write_cont' decides to | 1920 | GNUNET_STREAM_CompletionContinuation wc; |
1921 | // call SOCKET_close! | 1921 | void *wc_cls; |
1922 | if (NULL != socket->write_handle->write_cont) | 1922 | |
1923 | socket->write_handle->write_cont (socket->write_handle->write_cont_cls, | 1923 | wc = socket->write_handle->write_cont; |
1924 | GNUNET_STREAM_SHUTDOWN, 0); | 1924 | wc_cls = socket->write_handle->write_cont_cls; |
1925 | GNUNET_STREAM_io_write_cancel (socket->write_handle); | 1925 | GNUNET_STREAM_io_write_cancel (socket->write_handle); |
1926 | socket->write_handle = NULL; | 1926 | socket->write_handle = NULL; |
1927 | if (NULL != wc) | ||
1928 | wc (wc_cls, | ||
1929 | GNUNET_STREAM_SHUTDOWN, 0); | ||
1927 | } | 1930 | } |
1928 | return GNUNET_OK; | 1931 | return GNUNET_OK; |
1929 | } | 1932 | } |
@@ -2041,13 +2044,16 @@ handle_close (struct GNUNET_STREAM_Socket *socket, | |||
2041 | that that stream has been shutdown */ | 2044 | that that stream has been shutdown */ |
2042 | if (NULL != socket->write_handle) | 2045 | if (NULL != socket->write_handle) |
2043 | { | 2046 | { |
2044 | // FIXME: this breaks if 'write_cont' decides to | 2047 | GNUNET_STREAM_CompletionContinuation wc; |
2045 | // call SOCKET_close! | 2048 | void *wc_cls; |
2046 | if (NULL != socket->write_handle->write_cont) | 2049 | |
2047 | socket->write_handle->write_cont (socket->write_handle->write_cont_cls, | 2050 | wc = socket->write_handle->write_cont; |
2048 | GNUNET_STREAM_SHUTDOWN, 0); | 2051 | wc_cls = socket->write_handle->write_cont_cls; |
2049 | GNUNET_STREAM_io_write_cancel (socket->write_handle); | 2052 | GNUNET_STREAM_io_write_cancel (socket->write_handle); |
2050 | socket->write_handle = NULL; | 2053 | socket->write_handle = NULL; |
2054 | if (NULL != wc) | ||
2055 | wc (wc_cls, | ||
2056 | GNUNET_STREAM_SHUTDOWN, 0); | ||
2051 | } | 2057 | } |
2052 | return GNUNET_OK; | 2058 | return GNUNET_OK; |
2053 | } | 2059 | } |