diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-24 21:45:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-24 21:45:44 +0000 |
commit | 47d7779091557516cda70ab9038dc2d460b0b3bb (patch) | |
tree | 2c8a334a40268d8b3717332a9d7278909830fab7 /src/include/gnunet_client_lib.h | |
parent | 267b8b5e0e264627f334a18ae1bf3f3a88ff2e32 (diff) | |
download | gnunet-47d7779091557516cda70ab9038dc2d460b0b3bb.tar.gz gnunet-47d7779091557516cda70ab9038dc2d460b0b3bb.zip |
giving client API option for auto-retry, making more often use of transmit_and_get_response API and removing auto-retry code where enhanced client API can be used for it
Diffstat (limited to 'src/include/gnunet_client_lib.h')
-rw-r--r-- | src/include/gnunet_client_lib.h | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h index 20842de5c..c78df41c7 100644 --- a/src/include/gnunet_client_lib.h +++ b/src/include/gnunet_client_lib.h | |||
@@ -97,6 +97,12 @@ void GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | |||
97 | 97 | ||
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Transmit handle for client connections. | ||
101 | */ | ||
102 | struct GNUNET_CLIENT_TransmitHandle; | ||
103 | |||
104 | |||
105 | /** | ||
100 | * Ask the client to call us once the specified number of bytes | 106 | * Ask the client to call us once the specified number of bytes |
101 | * are free in the transmission buffer. May call the notify | 107 | * are free in the transmission buffer. May call the notify |
102 | * method immediately if enough space is available. | 108 | * method immediately if enough space is available. |
@@ -105,20 +111,35 @@ void GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | |||
105 | * @param size number of bytes to send | 111 | * @param size number of bytes to send |
106 | * @param timeout after how long should we give up (and call | 112 | * @param timeout after how long should we give up (and call |
107 | * notify with buf NULL and size 0)? | 113 | * notify with buf NULL and size 0)? |
114 | * @param auto_retry if the connection to the service dies, should we | ||
115 | * automatically re-connect and retry (within the timeout period) | ||
116 | * or should we immediately fail in this case? Pass GNUNET_YES | ||
117 | * if the caller does not care about temporary connection errors, | ||
118 | * for example because the protocol is stateless | ||
108 | * @param notify function to call | 119 | * @param notify function to call |
109 | * @param notify_cls closure for notify | 120 | * @param notify_cls closure for notify |
110 | * @return NULL if someone else is already waiting to be notified | 121 | * @return NULL if someone else is already waiting to be notified |
111 | * non-NULL if the notify callback was queued (can be used to cancel | 122 | * non-NULL if the notify callback was queued (can be used to cancel |
112 | * using GNUNET_CONNECTION_notify_transmit_ready_cancel) | 123 | * using GNUNET_CONNECTION_notify_transmit_ready_cancel) |
113 | */ | 124 | */ |
114 | struct GNUNET_CONNECTION_TransmitHandle | 125 | struct GNUNET_CLIENT_TransmitHandle |
115 | *GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *sock, | 126 | *GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *sock, |
116 | size_t size, | 127 | size_t size, |
117 | struct GNUNET_TIME_Relative timeout, | 128 | struct GNUNET_TIME_Relative timeout, |
129 | int auto_retry, | ||
118 | GNUNET_CONNECTION_TransmitReadyNotify | 130 | GNUNET_CONNECTION_TransmitReadyNotify |
119 | notify, void *notify_cls); | 131 | notify, |
132 | void *notify_cls); | ||
120 | 133 | ||
121 | 134 | ||
135 | /** | ||
136 | * Cancel a request for notification. | ||
137 | * | ||
138 | * @param th handle from the original request. | ||
139 | */ | ||
140 | void | ||
141 | GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHandle *th); | ||
142 | |||
122 | 143 | ||
123 | /** | 144 | /** |
124 | * Convenience API that combines sending a request | 145 | * Convenience API that combines sending a request |
@@ -131,13 +152,21 @@ struct GNUNET_CONNECTION_TransmitHandle | |||
131 | * @param hdr message to transmit | 152 | * @param hdr message to transmit |
132 | * @param timeout when to give up (for both transmission | 153 | * @param timeout when to give up (for both transmission |
133 | * and for waiting for a response) | 154 | * and for waiting for a response) |
155 | * @param auto_retry if the connection to the service dies, should we | ||
156 | * automatically re-connect and retry (within the timeout period) | ||
157 | * or should we immediately fail in this case? Pass GNUNET_YES | ||
158 | * if the caller does not care about temporary connection errors, | ||
159 | * for example because the protocol is stateless | ||
134 | * @param rn function to call with the response | 160 | * @param rn function to call with the response |
135 | * @param rn_cls closure for rn | 161 | * @param rn_cls closure for rn |
162 | * @return GNUNET_OK on success, GNUNET_SYSERR if a request | ||
163 | * is already pending | ||
136 | */ | 164 | */ |
137 | void | 165 | int |
138 | GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock, | 166 | GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock, |
139 | const struct GNUNET_MessageHeader *hdr, | 167 | const struct GNUNET_MessageHeader *hdr, |
140 | struct GNUNET_TIME_Relative timeout, | 168 | struct GNUNET_TIME_Relative timeout, |
169 | int auto_retry, | ||
141 | GNUNET_CLIENT_MessageHandler rn, | 170 | GNUNET_CLIENT_MessageHandler rn, |
142 | void *rn_cls); | 171 | void *rn_cls); |
143 | 172 | ||