diff options
author | Ben Pfaff <blp@nicira.com> | 2010-01-06 14:26:48 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-01-06 14:26:48 -0800 |
commit | 539e96f62300e4afab00e5906a28e3b89301d62e (patch) | |
tree | d91d559866c7a32d48613d2cae3a8b52c56bdb36 /lib/stream.c | |
parent | e0668bd1d448d6f17c20b9c7ba91344180809061 (diff) | |
download | openvswitch-539e96f62300e4afab00e5906a28e3b89301d62e.tar.gz |
stream: Add stream_run(), stream_run_wait() functions.
SSL, which will be added in an upcoming commit, requires some background
processing, which is best done in a "run" function in our architecture.
This commit adds stream_run() and stream_run_wait() and calls to them from
the places where they will be required.
Diffstat (limited to 'lib/stream.c')
-rw-r--r-- | lib/stream.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/stream.c b/lib/stream.c index 337fb5c75..d4f5de29e 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,8 @@ check_stream_classes(void) struct stream_class *class = stream_classes[i]; assert(class->name != NULL); assert(class->open != NULL); - if (class->close || class->recv || class->send || class->wait) { + if (class->close || class->recv || class->send || class->run + || class->run_wait || class->wait) { assert(class->close != NULL); assert(class->recv != NULL); assert(class->send != NULL); @@ -166,6 +167,8 @@ stream_open_block(const char *name, struct stream **streamp) error = stream_open(name, &stream); while (error == EAGAIN) { + stream_run(stream); + stream_run_wait(stream); stream_connect_wait(stream); poll_block(); error = stream_connect(stream); @@ -312,6 +315,28 @@ stream_send(struct stream *stream, const void *buffer, size_t n) : (stream->class->send)(stream, buffer, n)); } +/* Allows 'stream' to perform maintenance activities, such as flushing + * output buffers. */ +void +stream_run(struct stream *stream) +{ + if (stream->class->run) { + (stream->class->run)(stream); + } +} + +/* Arranges for the poll loop to wake up when 'stream' needs to perform + * maintenance activities. */ +void +stream_run_wait(struct stream *stream) +{ + if (stream->class->run_wait) { + (stream->class->run_wait)(stream); + } +} + +/* Arranges for the poll loop to wake up when 'stream' is ready to take an + * action of the given 'type'. */ void stream_wait(struct stream *stream, enum stream_wait_type wait) { |