You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2013/10/17 17:06:40 UTC
svn commit: r1533103 - in /qpid/proton/trunk/proton-c: CMakeLists.txt
src/messenger/messenger.c src/messenger/messenger.h
src/messenger/subscription.c src/messenger/subscription.h
Author: rhs
Date: Thu Oct 17 15:06:39 2013
New Revision: 1533103
URL: http://svn.apache.org/r1533103
Log:
split subscription out into a separate file
Added:
qpid/proton/trunk/proton-c/src/messenger/messenger.h
qpid/proton/trunk/proton-c/src/messenger/subscription.c
qpid/proton/trunk/proton-c/src/messenger/subscription.h
Modified:
qpid/proton/trunk/proton-c/CMakeLists.txt
qpid/proton/trunk/proton-c/src/messenger/messenger.c
Modified: qpid/proton/trunk/proton-c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/CMakeLists.txt?rev=1533103&r1=1533102&r2=1533103&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/CMakeLists.txt Thu Oct 17 15:06:39 2013
@@ -254,6 +254,7 @@ set (qpid-proton-core
src/sasl/sasl.c
src/messenger/messenger.c
+ src/messenger/subscription.c
src/messenger/store.c
src/messenger/transform.c
Modified: qpid/proton/trunk/proton-c/src/messenger/messenger.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger/messenger.c?rev=1533103&r1=1533102&r2=1533103&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/messenger/messenger.c (original)
+++ qpid/proton/trunk/proton-c/src/messenger/messenger.c Thu Oct 17 15:06:39 2013
@@ -34,6 +34,7 @@
#include "../platform_fmt.h"
#include "store.h"
#include "transform.h"
+#include "subscription.h"
typedef struct pn_link_ctx_t pn_link_ctx_t;
@@ -77,9 +78,7 @@ struct pn_messenger_t {
uint64_t next_tag;
pni_store_t *outgoing;
pni_store_t *incoming;
- pn_subscription_t *subscriptions;
- size_t sub_capacity;
- size_t sub_count;
+ pn_list_t *subscriptions;
pn_subscription_t *incoming_subscription;
pn_error_t *error;
pn_transform_t *routes;
@@ -92,19 +91,12 @@ struct pn_messenger_t {
bool worked;
};
-struct pn_subscription_t {
- char *scheme;
- void *context;
-};
-
typedef struct {
char *host;
char *port;
pn_subscription_t *subscription;
} pn_listener_ctx_t;
-pn_subscription_t *pn_subscription(pn_messenger_t *messenger, const char *scheme);
-
static pn_listener_ctx_t *pn_listener_ctx(pn_listener_t *lnr,
pn_messenger_t *messenger,
const char *scheme,
@@ -263,9 +255,7 @@ pn_messenger_t *pn_messenger(const char
m->next_tag = 0;
m->outgoing = pni_store();
m->incoming = pni_store();
- m->subscriptions = NULL;
- m->sub_capacity = 0;
- m->sub_count = 0;
+ m->subscriptions = pn_list(0, PN_REFCOUNT);
m->incoming_subscription = NULL;
m->error = pn_error();
m->routes = pn_transform();
@@ -280,6 +270,12 @@ pn_messenger_t *pn_messenger(const char
return m;
}
+int pni_messenger_add_subscription(pn_messenger_t *messenger, pn_subscription_t *subscription)
+{
+ return pn_list_add(messenger->subscriptions, subscription);
+}
+
+
const char *pn_messenger_name(pn_messenger_t *messenger)
{
return messenger->name;
@@ -391,10 +387,7 @@ void pn_messenger_free(pn_messenger_t *m
pn_error_free(messenger->error);
pni_store_free(messenger->incoming);
pni_store_free(messenger->outgoing);
- for (unsigned i = 0; i < messenger->sub_count; i++) {
- free(messenger->subscriptions[i].scheme);
- }
- free(messenger->subscriptions);
+ pn_free(messenger->subscriptions);
pn_free(messenger->rewrites);
pn_free(messenger->routes);
pn_free(messenger->credited);
@@ -769,7 +762,7 @@ void pni_messenger_reclaim(pn_messenger_
pn_connection_t *pn_messenger_connection(pn_messenger_t *messenger,
pn_connector_t *connector,
- char *scheme,
+ const char *scheme,
char *user,
char *pass,
char *host,
@@ -822,7 +815,7 @@ int pn_messenger_tsync(pn_messenger_t *m
messenger->worked = true;
pn_listener_ctx_t *ctx = (pn_listener_ctx_t *) pn_listener_context(l);
pn_subscription_t *sub = ctx->subscription;
- char *scheme = sub->scheme;
+ const char *scheme = pn_subscription_scheme(sub);
pn_connector_t *c = pn_listener_accept(l);
pn_transport_t *t = pn_connector_transport(c);
@@ -1059,27 +1052,6 @@ pn_connection_t *pn_messenger_resolve(pn
return connection;
}
-pn_subscription_t *pn_subscription(pn_messenger_t *messenger, const char *scheme)
-{
- PN_ENSURE(messenger->subscriptions, messenger->sub_capacity, messenger->sub_count + 1, pn_subscription_t);
- pn_subscription_t *sub = messenger->subscriptions + messenger->sub_count++;
- sub->scheme = pn_strdup(scheme);
- sub->context = NULL;
- return sub;
-}
-
-void *pn_subscription_get_context(pn_subscription_t *sub)
-{
- assert(sub);
- return sub->context;
-}
-
-void pn_subscription_set_context(pn_subscription_t *sub, void *context)
-{
- assert(sub);
- sub->context = context;
-}
-
pn_link_t *pn_messenger_link(pn_messenger_t *messenger, const char *address, bool sender)
{
char *name = NULL;
Added: qpid/proton/trunk/proton-c/src/messenger/messenger.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger/messenger.h?rev=1533103&view=auto
==============================================================================
--- qpid/proton/trunk/proton-c/src/messenger/messenger.h (added)
+++ qpid/proton/trunk/proton-c/src/messenger/messenger.h Thu Oct 17 15:06:39 2013
@@ -0,0 +1,29 @@
+#ifndef _PROTON_MESSENGER_H
+#define _PROTON_MESSENGER_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/messenger.h>
+
+int pni_messenger_add_subscription(pn_messenger_t *messenger, pn_subscription_t *subscription);
+
+#endif /* messenger.h */
Added: qpid/proton/trunk/proton-c/src/messenger/subscription.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger/subscription.c?rev=1533103&view=auto
==============================================================================
--- qpid/proton/trunk/proton-c/src/messenger/subscription.c (added)
+++ qpid/proton/trunk/proton-c/src/messenger/subscription.c Thu Oct 17 15:06:39 2013
@@ -0,0 +1,79 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/messenger.h>
+#include <proton/object.h>
+#include <assert.h>
+
+#include "messenger.h"
+
+struct pn_subscription_t {
+ pn_messenger_t *messenger;
+ pn_string_t *scheme;
+ void *context;
+};
+
+void pn_subscription_initialize(void *obj)
+{
+ pn_subscription_t *sub = (pn_subscription_t *) obj;
+ sub->messenger = NULL;
+ sub->scheme = pn_string(NULL);
+ sub->context = NULL;
+}
+
+void pn_subscription_finalize(void *obj)
+{
+ pn_subscription_t *sub = (pn_subscription_t *) obj;
+ pn_free(sub->scheme);
+}
+
+#define pn_subscription_hashcode NULL
+#define pn_subscription_compare NULL
+#define pn_subscription_inspect NULL
+
+pn_subscription_t *pn_subscription(pn_messenger_t *messenger, const char *scheme)
+{
+ static pn_class_t clazz = PN_CLASS(pn_subscription);
+ pn_subscription_t *sub = (pn_subscription_t *) pn_new(sizeof(pn_subscription_t), &clazz);
+ sub->messenger = messenger;
+ pn_string_set(sub->scheme, scheme);
+ pni_messenger_add_subscription(messenger, sub);
+ pn_decref(sub);
+ return sub;
+}
+
+const char *pn_subscription_scheme(pn_subscription_t *sub)
+{
+ assert(sub);
+ return pn_string_get(sub->scheme);
+}
+
+void *pn_subscription_get_context(pn_subscription_t *sub)
+{
+ assert(sub);
+ return sub->context;
+}
+
+void pn_subscription_set_context(pn_subscription_t *sub, void *context)
+{
+ assert(sub);
+ sub->context = context;
+}
Added: qpid/proton/trunk/proton-c/src/messenger/subscription.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger/subscription.h?rev=1533103&view=auto
==============================================================================
--- qpid/proton/trunk/proton-c/src/messenger/subscription.h (added)
+++ qpid/proton/trunk/proton-c/src/messenger/subscription.h Thu Oct 17 15:06:39 2013
@@ -0,0 +1,30 @@
+#ifndef _PROTON_SUBSCRIPTION_H
+#define _PROTON_SUBSCRIPTION_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <proton/messenger.h>
+
+pn_subscription_t *pn_subscription(pn_messenger_t *messenger, const char *scheme);
+const char *pn_subscription_scheme(pn_subscription_t *sub);
+
+#endif /* subscription.h */
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org