diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-11-16 20:48:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-11-16 20:48:40 +0000 |
commit | ec9484a55c24358836daa52d05f17bb3162d0052 (patch) | |
tree | 7fbe23bf9421e7b710f729e83ead898338ce466c /src | |
parent | 84d2e96422d2a67048cd92a8cd6a25dfb389f692 (diff) | |
download | gnunet-ec9484a55c24358836daa52d05f17bb3162d0052.tar.gz gnunet-ec9484a55c24358836daa52d05f17bb3162d0052.zip |
fix cont mess
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core_api.c | 80 |
1 files changed, 12 insertions, 68 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index fb975e731..28cec6724 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -143,6 +143,10 @@ struct ControlMessage | |||
143 | */ | 143 | */ |
144 | void *cont_cls; | 144 | void *cont_cls; |
145 | 145 | ||
146 | /** | ||
147 | * Transmit handle (if one is associated with this ControlMessage), or NULL. | ||
148 | */ | ||
149 | struct GNUNET_CORE_TransmitHandle *th; | ||
146 | }; | 150 | }; |
147 | 151 | ||
148 | 152 | ||
@@ -561,6 +565,7 @@ request_next_transmission (struct PeerRecord *pr) | |||
561 | cm->cont = &mark_control_message_sent; | 565 | cm->cont = &mark_control_message_sent; |
562 | cm->cont_cls = th; | 566 | cm->cont_cls = th; |
563 | th->cm = cm; | 567 | th->cm = cm; |
568 | cm->th = th; | ||
564 | smr = (struct SendMessageRequest*) &cm[1]; | 569 | smr = (struct SendMessageRequest*) &cm[1]; |
565 | smr->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST); | 570 | smr->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST); |
566 | smr->header.size = htons (sizeof (struct SendMessageRequest)); | 571 | smr->header.size = htons (sizeof (struct SendMessageRequest)); |
@@ -659,8 +664,12 @@ transmit_message (void *cls, | |||
659 | GNUNET_CONTAINER_DLL_remove (h->pending_head, | 664 | GNUNET_CONTAINER_DLL_remove (h->pending_head, |
660 | h->pending_tail, | 665 | h->pending_tail, |
661 | cm); | 666 | cm); |
667 | if (cm->th != NULL) | ||
668 | cm->th->cm = NULL; | ||
662 | if (NULL != cm->cont) | 669 | if (NULL != cm->cont) |
663 | cm->cont (cm->cont_cls, NULL); | 670 | GNUNET_SCHEDULER_add_continuation (cm->cont, |
671 | cm->cont_cls, | ||
672 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
664 | GNUNET_free (cm); | 673 | GNUNET_free (cm); |
665 | trigger_next_request (h, GNUNET_NO); | 674 | trigger_next_request (h, GNUNET_NO); |
666 | return msize; | 675 | return msize; |
@@ -1403,6 +1412,8 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) | |||
1403 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, | 1412 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, |
1404 | handle->pending_tail, | 1413 | handle->pending_tail, |
1405 | cm); | 1414 | cm); |
1415 | if (cm->th != NULL) | ||
1416 | cm->th->cm = NULL; | ||
1406 | cm->cont (cm->cont_cls, NULL); | 1417 | cm->cont (cm->cont_cls, NULL); |
1407 | GNUNET_free (cm); | 1418 | GNUNET_free (cm); |
1408 | } | 1419 | } |
@@ -1885,71 +1896,4 @@ GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequest | |||
1885 | } | 1896 | } |
1886 | 1897 | ||
1887 | 1898 | ||
1888 | #if NEW | ||
1889 | /* ********************* GNUNET_CORE_iterate_peers *********************** */ | ||
1890 | |||
1891 | /** | ||
1892 | * Context for 'iterate_peers' helper function. | ||
1893 | */ | ||
1894 | struct IterationContext | ||
1895 | { | ||
1896 | /** | ||
1897 | * Callback to call. | ||
1898 | */ | ||
1899 | GNUNET_CORE_ConnectEventHandler peer_cb; | ||
1900 | |||
1901 | /** | ||
1902 | * Closure for 'peer_cb'. | ||
1903 | */ | ||
1904 | void *cb_cls; | ||
1905 | }; | ||
1906 | |||
1907 | |||
1908 | /** | ||
1909 | * Call callback for each peer. | ||
1910 | * | ||
1911 | * @param cls the 'struct IterationContext' | ||
1912 | * @param hc peer identity, not used | ||
1913 | * @param value the 'struct PeerRecord' | ||
1914 | * @return GNUNET_YES (continue iteration) | ||
1915 | */ | ||
1916 | static int | ||
1917 | iterate_peers (void *cls, | ||
1918 | const GNUNET_HashCode *hc, | ||
1919 | void *value) | ||
1920 | { | ||
1921 | struct IterationContext *ic = cls; | ||
1922 | struct PeerRecord *pr = value; | ||
1923 | |||
1924 | ic->peer_cb (ic->cb_cls, | ||
1925 | &pr->peer, | ||
1926 | NULL /* FIXME: pass atsi? */); | ||
1927 | return GNUNET_YES; | ||
1928 | } | ||
1929 | |||
1930 | |||
1931 | /** | ||
1932 | * Obtain statistics and/or change preferences for the given peer. | ||
1933 | * | ||
1934 | * @param h handle to core | ||
1935 | * @param peer_cb function to call with the peer information | ||
1936 | * @param cb_cls closure for peer_cb | ||
1937 | * @return GNUNET_OK if iterating, GNUNET_SYSERR on error | ||
1938 | */ | ||
1939 | int | ||
1940 | GNUNET_CORE_iterate_peers (struct GNUNET_CORE_Handle *h, | ||
1941 | GNUNET_CORE_ConnectEventHandler peer_cb, | ||
1942 | void *cb_cls) | ||
1943 | { | ||
1944 | struct IterationContext ic; | ||
1945 | |||
1946 | ic.peer_cb = peer_cb; | ||
1947 | ic.cb_cls = cb_cls; | ||
1948 | GNUNET_CONTAINER_multihashmap_iterate (h->peers, | ||
1949 | &iterate_peers, | ||
1950 | &ic); | ||
1951 | return GNUNET_OK; | ||
1952 | } | ||
1953 | #endif | ||
1954 | |||
1955 | /* end of core_api.c */ | 1899 | /* end of core_api.c */ |