diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-04 08:50:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-04 08:50:09 +0000 |
commit | 6aefa4ac85435c8e7afb86e4e6daef77da69709a (patch) | |
tree | fe3241f641088070ef4a909f627482f8252bf0a9 /src/fs/fs_publish.c | |
parent | db9926f66da9571020fba8f1f2fa0014d1b65b0f (diff) | |
download | gnunet-6aefa4ac85435c8e7afb86e4e6daef77da69709a.tar.gz gnunet-6aefa4ac85435c8e7afb86e4e6daef77da69709a.zip |
generating SUSPEND events
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r-- | src/fs/fs_publish.c | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 4101174bb..0c4ebba7b 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -930,6 +930,46 @@ fip_signal_start(void *cls, | |||
930 | 930 | ||
931 | 931 | ||
932 | /** | 932 | /** |
933 | * Signal the FS's progress function that we are suspending | ||
934 | * an upload. | ||
935 | * | ||
936 | * @param cls closure (of type "struct GNUNET_FS_PublishContext*") | ||
937 | * @param fi the entry in the publish-structure | ||
938 | * @param length length of the file or directory | ||
939 | * @param meta metadata for the file or directory (can be modified) | ||
940 | * @param uri pointer to the keywords that will be used for this entry (can be modified) | ||
941 | * @param anonymity pointer to selected anonymity level (can be modified) | ||
942 | * @param priority pointer to selected priority (can be modified) | ||
943 | * @param expirationTime pointer to selected expiration time (can be modified) | ||
944 | * @param client_info pointer to client context set upon creation (can be modified) | ||
945 | * @return GNUNET_OK to continue (always) | ||
946 | */ | ||
947 | static int | ||
948 | fip_signal_suspend(void *cls, | ||
949 | struct GNUNET_FS_FileInformation *fi, | ||
950 | uint64_t length, | ||
951 | struct GNUNET_CONTAINER_MetaData *meta, | ||
952 | struct GNUNET_FS_Uri **uri, | ||
953 | uint32_t *anonymity, | ||
954 | uint32_t *priority, | ||
955 | struct GNUNET_TIME_Absolute *expirationTime, | ||
956 | void **client_info) | ||
957 | { | ||
958 | struct GNUNET_FS_PublishContext*sc = cls; | ||
959 | struct GNUNET_FS_ProgressInfo pi; | ||
960 | uint64_t off; | ||
961 | |||
962 | GNUNET_free_non_null (fi->serialization); | ||
963 | fi->serialization = NULL; | ||
964 | off = (fi->chk_uri == NULL) ? 0 : length; | ||
965 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; | ||
966 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, sc, fi, off)); | ||
967 | *client_info = NULL; | ||
968 | return GNUNET_OK; | ||
969 | } | ||
970 | |||
971 | |||
972 | /** | ||
933 | * Create SUSPEND event for the given publish operation | 973 | * Create SUSPEND event for the given publish operation |
934 | * and then clean up our state (without stop signal). | 974 | * and then clean up our state (without stop signal). |
935 | * | 975 | * |
@@ -940,9 +980,16 @@ publish_signal_suspend (void *cls) | |||
940 | { | 980 | { |
941 | struct GNUNET_FS_PublishContext *pc = cls; | 981 | struct GNUNET_FS_PublishContext *pc = cls; |
942 | 982 | ||
983 | if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task) | ||
984 | { | ||
985 | GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task); | ||
986 | pc->upload_task = GNUNET_SCHEDULER_NO_TASK; | ||
987 | } | ||
988 | GNUNET_FS_file_information_inspect (pc->fi, | ||
989 | &fip_signal_suspend, | ||
990 | pc); | ||
943 | GNUNET_FS_end_top (pc->h, pc->top); | 991 | GNUNET_FS_end_top (pc->h, pc->top); |
944 | /* FIXME: signal! */ | 992 | publish_cleanup (pc); |
945 | GNUNET_free (pc); | ||
946 | } | 993 | } |
947 | 994 | ||
948 | /** | 995 | /** |
@@ -1074,7 +1121,10 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) | |||
1074 | { | 1121 | { |
1075 | GNUNET_FS_end_top (pc->h, pc->top); | 1122 | GNUNET_FS_end_top (pc->h, pc->top); |
1076 | if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task) | 1123 | if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task) |
1077 | GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task); | 1124 | { |
1125 | GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task); | ||
1126 | pc->upload_task = GNUNET_SCHEDULER_NO_TASK; | ||
1127 | } | ||
1078 | if (pc->serialization != NULL) | 1128 | if (pc->serialization != NULL) |
1079 | { | 1129 | { |
1080 | GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization); | 1130 | GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization); |