Skip to content

Commit

Permalink
these functions don't need to be public
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Nov 19, 2024
1 parent c597d40 commit 81c9bab
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
86 changes: 44 additions & 42 deletions src/lib/bio/retry.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,27 @@ static void fr_bio_retry_release(fr_bio_retry_t *my, fr_bio_retry_entry_t *item,
fr_bio_retry_list_insert_head(&my->free, item);
}

/** Writes are blocked.
*
*/
static int fr_bio_retry_write_blocked(fr_bio_t *bio)
{
fr_bio_retry_t *my = talloc_get_type_abort(bio, fr_bio_retry_t);

if (my->info.write_blocked) {
fr_assert(!my->ev);
return 1;
}

my->info.write_blocked = true;

fr_bio_retry_timer_clear(my);
if (fr_bio_retry_expiry_timer_reset(my) < 0) return fr_bio_error(GENERIC);

return 1;
}


/** Write one item.
*
* @return
Expand Down Expand Up @@ -390,6 +411,29 @@ static int fr_bio_retry_write_delayed(fr_bio_retry_t *my, fr_time_t now)
}


/** Resume writes.
*
* On resume, we try to flush any pending packets which should have been sent.
*/
static int fr_bio_retry_write_resume(fr_bio_t *bio)
{
fr_bio_retry_t *my = talloc_get_type_abort(bio, fr_bio_retry_t);
int rcode;

if (!my->info.write_blocked) return 1;

rcode = fr_bio_retry_write_delayed(my, fr_time());
if (rcode <= 0) return rcode;

my->info.write_blocked = false;

fr_bio_retry_timer_clear(my);
(void) fr_bio_retry_timer_reset(my);

return 1;
}


/** There's a partial packet written. Write all of that one first, before writing another packet.
*
* The packet can either be cancelled, or IO blocked. In either case, we must write the full packet before
Expand Down Expand Up @@ -1147,45 +1191,3 @@ fr_bio_retry_entry_t *fr_bio_retry_item_reserve(fr_bio_t *bio)
return item;
}


/** Writes are blocked.
*
*/
int fr_bio_retry_write_blocked(fr_bio_t *bio)
{
fr_bio_retry_t *my = talloc_get_type_abort(bio, fr_bio_retry_t);

if (my->info.write_blocked) {
fr_assert(!my->ev);
return 1;
}

my->info.write_blocked = true;

fr_bio_retry_timer_clear(my);
(void) fr_bio_retry_expiry_timer_reset(my);

return 1;
}

/** Resume writes.
*
* On resume, we try to flush any pending packets which should have been sent.
*/
int fr_bio_retry_write_resume(fr_bio_t *bio)
{
fr_bio_retry_t *my = talloc_get_type_abort(bio, fr_bio_retry_t);
int rcode;

if (!my->info.write_blocked) return 1;

rcode = fr_bio_retry_write_delayed(my, fr_time());
if (rcode <= 0) return rcode;

my->info.write_blocked = false;

fr_bio_retry_timer_clear(my);
(void) fr_bio_retry_timer_reset(my);

return 1;
}
3 changes: 0 additions & 3 deletions src/lib/bio/retry.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,4 @@ size_t fr_bio_retry_outstanding(fr_bio_t *bio) CC_HINT(nonnull);

fr_bio_retry_entry_t *fr_bio_retry_item_reserve(fr_bio_t *bio) CC_HINT(nonnull);

int fr_bio_retry_write_blocked(fr_bio_t *bio) CC_HINT(nonnull);
int fr_bio_retry_write_resume(fr_bio_t *bio) CC_HINT(nonnull);

#undef _CONST

0 comments on commit 81c9bab

Please sign in to comment.