[PATCH] cvr/pn_direct_conn: ->status data type to enum

0 views
Skip to first unread message

Octavio Alvarez

unread,
Feb 11, 2010, 6:23:38 PM2/11/10
to felipe.c...@gmail.com, msn-...@googlegroups.com, Octavio Alvarez
For code readability purposes, here I change the
pn_direct_conn->status field from int to enum and
its currently used values in all found instances.

Signed-off-by: Octavio Alvarez <alva...@alvarezp.ods.org>
---
cvr/pn_direct_conn.c | 8 ++++----
cvr/pn_direct_conn.h | 8 +++++++-
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/cvr/pn_direct_conn.c b/cvr/pn_direct_conn.c
index cb83d19..a950195 100644
--- a/cvr/pn_direct_conn.c
+++ b/cvr/pn_direct_conn.c
@@ -41,7 +41,7 @@ static void
foo_cb(struct pn_direct_conn *direct_conn,
void *data)
{
- direct_conn->status = 1;
+ direct_conn->status = PN_DIRECT_CONN_STATUS_CONNECTING;
pn_direct_conn_send_handshake(direct_conn);
}

@@ -149,7 +149,7 @@ pn_direct_conn_send_msg(struct pn_direct_conn *direct_conn, MsnMessage *msg)

body = msn_message_gen_slp_body(msg, &body_len);

- if (direct_conn->status == 1) {
+ if (direct_conn->status == PN_DIRECT_CONN_STATUS_CONNECTING) {
async_write(direct_conn, NULL, NULL, body, body_len, NULL, NULL);
goto leave;
}
@@ -185,8 +185,8 @@ pn_direct_conn_process_chunk(struct pn_direct_conn *direct_conn,
msg = msn_message_new_msnslp();
msn_message_parse_slp_body(msg, buf, bytes_read);

- if (direct_conn->status == 1) {
- direct_conn->status = 2;
+ if (direct_conn->status == PN_DIRECT_CONN_STATUS_CONNECTING) {
+ direct_conn->status = PN_DIRECT_CONN_STATUS_OPEN;
got_nonce(direct_conn, msg);
return;
}
diff --git a/cvr/pn_direct_conn.h b/cvr/pn_direct_conn.h
index cff69ec..d70da70 100644
--- a/cvr/pn_direct_conn.h
+++ b/cvr/pn_direct_conn.h
@@ -30,6 +30,12 @@ struct pn_direct_conn;

typedef void (*pn_io_cb_t) (struct pn_direct_conn *direct_conn, void *data);

+enum pn_direct_conn_status {
+ PN_DIRECT_CONN_STATUS_UNKNOWN = 0,
+ PN_DIRECT_CONN_STATUS_CONNECTING,
+ PN_DIRECT_CONN_STATUS_OPEN
+};
+
struct pn_direct_conn {
struct pn_peer_link *link;
struct pn_peer_call *initial_call;
@@ -52,7 +58,7 @@ struct pn_direct_conn {
void *io_cb_data;

MsnMessage *last_msg;
- int status;
+ enum pn_direct_conn_status status;

GQueue *addrs;
};
--
1.6.3.3

Octavio Alvarez

unread,
Feb 10, 2010, 4:58:54 PM2/10/10
to msn-...@googlegroups.com, Octavio Alvarez

Felipe Contreras

unread,
Feb 12, 2010, 4:08:46 AM2/12/10
to Octavio Alvarez, msn-...@googlegroups.com
On Fri, Feb 12, 2010 at 1:23 AM, Octavio Alvarez
<alva...@alvarezp.ods.org> wrote:
> For code readability purposes, here I change the
> pn_direct_conn->status field from int to enum and
> its currently used values in all found instances.

Thanks, I should have done this but was too lazy :P

> --- a/cvr/pn_direct_conn.h
> +++ b/cvr/pn_direct_conn.h
> @@ -30,6 +30,12 @@ struct pn_direct_conn;
>
>  typedef void (*pn_io_cb_t) (struct pn_direct_conn *direct_conn, void *data);
>
> +enum pn_direct_conn_status {
> +    PN_DIRECT_CONN_STATUS_UNKNOWN = 0,

No need to specify the first one as 0.

> +    PN_DIRECT_CONN_STATUS_CONNECTING,
> +    PN_DIRECT_CONN_STATUS_OPEN
> +};

I'll apply the patch with the aforementioned change.

Cheers.

--
Felipe Contreras

Felipe Contreras

unread,
Feb 12, 2010, 4:09:15 AM2/12/10
to Octavio Alvarez, msn-...@googlegroups.com
On Wed, Feb 10, 2010 at 11:58 PM, Octavio Alvarez
<alva...@alvarezp.ods.org> wrote:
> For code readability purposes, here I change the
> pn_direct_conn->status field from int to enum and
> its currently used values in all found instances.

Why did you send this again?

--
Felipe Contreras

Felipe Contreras

unread,
Feb 12, 2010, 1:19:57 PM2/12/10
to Octavio Alvarez, msn-...@googlegroups.com
On Fri, Feb 12, 2010 at 7:34 PM, Octavio Alvarez
<alva...@alvarezp.ods.org> wrote:

> On Fri, 12 Feb 2010 01:09:15 -0800, Felipe Contreras
> <felipe.c...@gmail.com> wrote:
>> Why did you send this again?
>
> Because I sent it on Wednesday to the ML with Cc
> to myself. I got it immediately. However, in the
> ML it didn't.
>
> I noticed other messages (like yours) were delivered
> by the ML quick enough.

Yeah, if you are not subscribed your messages go into moderation.

--
Felipe Contreras

Octavio Alvarez

unread,
Feb 12, 2010, 12:34:01 PM2/12/10
to Felipe Contreras, msn-...@googlegroups.com
On Fri, 12 Feb 2010 01:09:15 -0800, Felipe Contreras
<felipe.c...@gmail.com> wrote:

Because I sent it on Wednesday to the ML with Cc


to myself. I got it immediately. However, in the
ML it didn't.

I noticed other messages (like yours) were delivered
by the ML quick enough.

I assumed a problem with the ML or my subscription to
it. (And now I wonder why it took 2 days to appear.)

Given the above, I resent it, but this time with Cc
to you.

Thanks.

Octavio Alvarez

unread,
Feb 12, 2010, 1:24:23 PM2/12/10
to Felipe Contreras, msn-...@googlegroups.com
On Fri, 12 Feb 2010 10:19:57 -0800, Felipe Contreras
<felipe.c...@gmail.com> wrote:

> On Fri, Feb 12, 2010 at 7:34 PM, Octavio Alvarez
> <alva...@alvarezp.ods.org> wrote:
>> On Fri, 12 Feb 2010 01:09:15 -0800, Felipe Contreras
>> <felipe.c...@gmail.com> wrote:
>>> Why did you send this again?
>>
>> Because I sent it on Wednesday to the ML with Cc
>> to myself. I got it immediately. However, in the
>> ML it didn't.
>>
>> I noticed other messages (like yours) were delivered
>> by the ML quick enough.
>
> Yeah, if you are not subscribed your messages go into moderation.
>

I am subscribed. I just got this message through the ML,
addressed to the same account I used for sending.

Reply all
Reply to author
Forward
0 new messages