<div dir="ltr">that makes sense, ack<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 17, 2014 at 2:20 PM, Christophe Fergeau <span dir="ltr"><<a href="mailto:cfergeau@redhat.com" target="_blank">cfergeau@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">9feed69 moved the async reader code to RedsStream so that it can be used<br>
for the SASL authentication code. In particular, it introduced a<br>
RedsStream::async_read member which is used by the SASL authentication code<br>
for its async operations.<br>
<br>
However, what was not done is to remove the now redundant<br>
RedLinkInfo::async_read field. This causes failures when using SASL<br>
authentication as the async read error callback is getting set<br>
on the RedLinkInfo::async_read structure, but then the SASL code is trying<br>
to use the RedeStream::async_read structure for its async IOs, which do not<br>
have the needed error callback set.<br>
<br>
This commit makes use of the newly introduced reds_stream_async_read()<br>
helper in order to make use of RedsStream::async_read.<br>
---<br>
server/reds.c | 44 +++++++++++++++++++-------------------------<br>
1 file changed, 19 insertions(+), 25 deletions(-)<br>
<br>
diff --git a/server/reds.c b/server/reds.c<br>
index 2ef4aad..c1c0efc 100644<br>
--- a/server/reds.c<br>
+++ b/server/reds.c<br>
@@ -123,7 +123,6 @@ static RedsState *reds = NULL;<br>
<br>
typedef struct RedLinkInfo {<br>
RedsStream *stream;<br>
- AsyncRead async_read;<br>
SpiceLinkHeader link_header;<br>
SpiceLinkMess *link_mess;<br>
int mess_pos;<br>
@@ -1873,12 +1872,9 @@ end:<br>
<br>
static void reds_get_spice_ticket(RedLinkInfo *link)<br>
{<br>
- AsyncRead *obj = &link->async_read;<br>
-<br>
- obj->now = (uint8_t *)&link->tiTicketing.encrypted_ticket.encrypted_data;<br>
- obj->end = obj->now + link->tiTicketing.rsa_size;<br>
- obj->done = reds_handle_ticket;<br>
- async_read_handler(0, 0, &link->async_read);<br>
+ reds_stream_async_read(link->stream,<br>
+ (uint8_t *)&link->tiTicketing.encrypted_ticket.encrypted_data,<br>
+ link->tiTicketing.rsa_size, reds_handle_ticket, link);<br>
}<br>
<br>
#if HAVE_SASL<br>
@@ -2041,7 +2037,6 @@ static void reds_handle_read_link_done(void *opaque)<br>
{<br>
RedLinkInfo *link = (RedLinkInfo *)opaque;<br>
SpiceLinkMess *link_mess = link->link_mess;<br>
- AsyncRead *obj = &link->async_read;<br>
uint32_t num_caps = link_mess->num_common_caps + link_mess->num_channel_caps;<br>
uint32_t *caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);<br>
int auth_selection;<br>
@@ -2083,10 +2078,11 @@ static void reds_handle_read_link_done(void *opaque)<br>
spice_warning("Peer doesn't support AUTH selection");<br>
reds_get_spice_ticket(link);<br>
} else {<br>
- obj->now = (uint8_t *)&link->auth_mechanism;<br>
- obj->end = obj->now + sizeof(SpiceLinkAuthMechanism);<br>
- obj->done = reds_handle_auth_mechanism;<br>
- async_read_handler(0, 0, &link->async_read);<br>
+ reds_stream_async_read(link->stream,<br>
+ (uint8_t *)&link->auth_mechanism,<br>
+ sizeof(SpiceLinkAuthMechanism),<br>
+ reds_handle_auth_mechanism,<br>
+ link);<br>
}<br>
}<br>
<br>
@@ -2108,7 +2104,6 @@ static void reds_handle_read_header_done(void *opaque)<br>
{<br>
RedLinkInfo *link = (RedLinkInfo *)opaque;<br>
SpiceLinkHeader *header = &link->link_header;<br>
- AsyncRead *obj = &link->async_read;<br>
<br>
if (header->magic != SPICE_MAGIC) {<br>
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_MAGIC);<br>
@@ -2137,22 +2132,21 @@ static void reds_handle_read_header_done(void *opaque)<br>
<br>
link->link_mess = spice_malloc(header->size);<br>
<br>
- obj->now = (uint8_t *)link->link_mess;<br>
- obj->end = obj->now + header->size;<br>
- obj->done = reds_handle_read_link_done;<br>
- async_read_handler(0, 0, &link->async_read);<br>
+ reds_stream_async_read(link->stream,<br>
+ (uint8_t *)link->link_mess,<br>
+ header->size,<br>
+ reds_handle_read_link_done,<br>
+ link);<br>
}<br>
<br>
static void reds_handle_new_link(RedLinkInfo *link)<br>
{<br>
- AsyncRead *obj = &link->async_read;<br>
- obj->opaque = link;<br>
- obj->stream = link->stream;<br>
- obj->now = (uint8_t *)&link->link_header;<br>
- obj->end = (uint8_t *)((SpiceLinkHeader *)&link->link_header + 1);<br>
- obj->done = reds_handle_read_header_done;<br>
- obj->error = reds_handle_link_error;<br>
- async_read_handler(0, 0, &link->async_read);<br>
+ reds_stream_set_async_error_handler(link->stream, reds_handle_link_error);<br>
+ reds_stream_async_read(link->stream,<br>
+ (uint8_t *)&link->link_header,<br>
+ sizeof(SpiceLinkHeader),<br>
+ reds_handle_read_header_done,<br>
+ link);<br>
}<br>
<br>
static void reds_handle_ssl_accept(int fd, int event, void *data)<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.5.3<br>
<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Marc-André Lureau
</div>