From c9c6117c66ddd124f19b824a2e18fc044a042c9b Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 15 Dec 2023 10:17:29 -0500 Subject: [PATCH] MT#55283 update all flags to 64 bit Change-Id: I8635c29cab5843b5bf8092f30a093871eeb37f29 --- daemon/call.c | 4 ++-- daemon/ice.c | 2 +- daemon/recording.c | 4 ++-- daemon/redis.c | 22 ++++++++++++---------- include/call.h | 12 ++++++------ include/helpers.h | 26 +++++++++++++------------- include/ice.h | 4 ++-- recording-daemon/metafile.c | 5 +++-- 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 2ebf41aaf..e0cecaf62 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2085,11 +2085,11 @@ get: static void __dtls_logic(const sdp_ng_flags *flags, struct call_media *other_media, struct stream_params *sp) { - unsigned int tmp; + uint64_t tmp; call_t *call = other_media->call; /* active and passive are from our POV */ - tmp = other_media->media_flags; + tmp = atomic64_get_na(&other_media->media_flags); bf_copy(&other_media->media_flags, MEDIA_FLAG_SETUP_PASSIVE, &sp->sp_flags, SP_FLAG_SETUP_ACTIVE); bf_copy(&other_media->media_flags, MEDIA_FLAG_SETUP_ACTIVE, diff --git a/daemon/ice.c b/daemon/ice.c index f21bc3c97..7f1766c22 100644 --- a/daemon/ice.c +++ b/daemon/ice.c @@ -423,7 +423,7 @@ static void __ice_agent_initialize(struct ice_agent *ag) { ag->pair_hash = candidate_pair_ht_new(); ag->transaction_hash = transaction_ht_new(); ag->foundation_hash = foundation_ht_new(); - ag->agent_flags = 0; + atomic64_set_na(&ag->agent_flags, 0); bf_copy(&ag->agent_flags, ICE_AGENT_CONTROLLING, &media->media_flags, MEDIA_FLAG_ICE_CONTROLLING); bf_copy(&ag->agent_flags, ICE_AGENT_LITE_SELF, &media->media_flags, MEDIA_FLAG_ICE_LITE_SELF); ag->logical_intf = media->logical_intf; diff --git a/daemon/recording.c b/daemon/recording.c index 6e0ea2b36..05118f081 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -897,9 +897,9 @@ static void setup_stream_proc(struct packet_stream *stream) { if (ML_ISSET(ml, NO_RECORDING)) return; - len = snprintf(buf, sizeof(buf), "TAG %u MEDIA %u TAG-MEDIA %u COMPONENT %u FLAGS %u", + len = snprintf(buf, sizeof(buf), "TAG %u MEDIA %u TAG-MEDIA %u COMPONENT %u FLAGS %" PRIu64, ml->unique_id, media->unique_id, media->index, stream->component, - stream->ps_flags); + atomic64_get_na(&stream->ps_flags)); append_meta_chunk(recording, buf, len, "STREAM %u details", stream->unique_id); len = snprintf(buf, sizeof(buf), "tag-%u-media-%u-component-%u-%s-id-%u", diff --git a/daemon/redis.c b/daemon/redis.c index 3d06606f5..13addc970 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1460,7 +1460,7 @@ static int redis_streams(call_t *c, struct redis_list *streams) { return -1; atomic64_set_na(&ps->last_packet, time(NULL)); - if (redis_hash_get_unsigned((unsigned int *) &ps->ps_flags, rh, "ps_flags")) + if (redis_hash_get_a64(&ps->ps_flags, rh, "ps_flags")) return -1; if (redis_hash_get_unsigned((unsigned int *) &ps->component, rh, "component")) return -1; @@ -1483,6 +1483,7 @@ static int redis_streams(call_t *c, struct redis_list *streams) { static int redis_tags(call_t *c, struct redis_list *tags, JsonReader *root_reader) { unsigned int i; int ii; + atomic64 a64; struct redis_hash *rh; struct call_monologue *ml; str s; @@ -1507,8 +1508,8 @@ static int redis_tags(call_t *c, struct redis_list *tags, JsonReader *root_reade redis_hash_get_time_t(&ml->deleted, rh, "deleted"); if (!redis_hash_get_int(&ii, rh, "block_dtmf")) ml->block_dtmf = ii; - if (!redis_hash_get_int(&ii, rh, "ml_flags")) - ml->ml_flags = ii; + if (!redis_hash_get_a64(&a64, rh, "ml_flags")) + ml->ml_flags = a64; if (redis_hash_get_str(&s, rh, "desired_family")) return -1; @@ -1590,7 +1591,7 @@ static int json_medias(call_t *c, struct redis_list *medias, struct redis_list * med->logical_intf = get_logical_interface(NULL, med->desired_family, 0); } - if (redis_hash_get_unsigned((unsigned int *) &med->media_flags, rh, + if (redis_hash_get_a64(&med->media_flags, rh, "media_flags")) return -1; @@ -1952,6 +1953,7 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign) const char *err = 0; int i; + atomic64 a64; JsonReader *root_reader =0; JsonParser *parser =0; @@ -2033,8 +2035,8 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign) sockaddr_parse_any_str(&c->created_from_addr, &id); if (!redis_hash_get_int(&i, &call, "block_dtmf")) c->block_dtmf = i; - if (!redis_hash_get_int(&i, &call, "call_flags")) - c->call_flags = i; + if (!redis_hash_get_a64(&a64, &call, "call_flags")) + c->call_flags = a64; err = "missing 'redis_hosted_db' value"; if (redis_hash_get_unsigned((unsigned int *) &c->redis_hosted_db, &call, "redis_hosted_db")) @@ -2363,7 +2365,7 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE("redis_hosted_db","%u", c->redis_hosted_db); JSON_SET_SIMPLE_STR("recording_metadata", &c->metadata); JSON_SET_SIMPLE("block_dtmf","%i", c->block_dtmf); - JSON_SET_SIMPLE("call_flags","%i", c->call_flags); + JSON_SET_SIMPLE("call_flags", "%" PRIu64, atomic64_get_na(&c->call_flags)); if ((rec = c->recording)) JSON_SET_SIMPLE_CSTR("recording_meta_prefix", rec->meta_prefix); @@ -2410,7 +2412,7 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE("sfd","%u",ps->selected_sfd ? ps->selected_sfd->unique_id : -1); JSON_SET_SIMPLE("rtcp_sibling","%u",ps->rtcp_sibling ? ps->rtcp_sibling->unique_id : -1); JSON_SET_SIMPLE("last_packet",UINT64F,atomic64_get(&ps->last_packet)); - JSON_SET_SIMPLE("ps_flags","%u",ps->ps_flags); + JSON_SET_SIMPLE("ps_flags", "%" PRIu64, atomic64_get_na(&ps->ps_flags)); JSON_SET_SIMPLE("component","%u",ps->component); JSON_SET_SIMPLE_CSTR("endpoint",endpoint_print_buf(&ps->endpoint)); JSON_SET_SIMPLE_CSTR("advertised_endpoint",endpoint_print_buf(&ps->advertised_endpoint)); @@ -2478,7 +2480,7 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE("created", "%llu", (long long unsigned) ml->created); JSON_SET_SIMPLE("deleted", "%llu", (long long unsigned) ml->deleted); JSON_SET_SIMPLE("block_dtmf", "%i", ml->block_dtmf); - JSON_SET_SIMPLE("ml_flags","%u", ml->ml_flags); + JSON_SET_SIMPLE("ml_flags", "%" PRIu64, atomic64_get_na(&ml->ml_flags)); JSON_SET_SIMPLE_CSTR("desired_family", ml->desired_family ? ml->desired_family->rfc_name : ""); if (ml->logical_intf) JSON_SET_SIMPLE_STR("logical_intf", &ml->logical_intf->name); @@ -2589,7 +2591,7 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE_CSTR("desired_family", media->desired_family ? media->desired_family->rfc_name : ""); JSON_SET_SIMPLE_STR("logical_intf", &media->logical_intf->name); JSON_SET_SIMPLE("ptime","%i", media->ptime); - JSON_SET_SIMPLE("media_flags","%u", media->media_flags); + JSON_SET_SIMPLE("media_flags", "%" PRIu64, atomic64_get_na(&media->media_flags)); json_update_sdes_params(builder, "media", media->unique_id, "sdes_in", &media->sdes_in); diff --git a/include/call.h b/include/call.h index 3dae2e902..e12cfba45 100644 --- a/include/call.h +++ b/include/call.h @@ -334,7 +334,7 @@ struct stream_params { str direction[2]; sockfamily_t *desired_family; struct dtls_fingerprint fingerprint; - unsigned int sp_flags; + atomic64 sp_flags; struct codec_store codecs; candidate_q ice_candidates; /* slice-alloc'd */ str ice_ufrag; @@ -419,7 +419,7 @@ struct packet_stream { atomic64 last_packet; GHashTable *rtp_stats; /* LOCK: call->master_lock */ struct rtp_stats *rtp_stats_cache; - unsigned int stats_flags; + atomic64 stats_flags; enum endpoint_learning el_flags; #if RTP_LOOP_PROTECT @@ -432,7 +432,7 @@ struct packet_stream { X509 *dtls_cert; /* LOCK: in_lock */ /* in_lock must be held for SETTING these: */ - volatile unsigned int ps_flags; + atomic64 ps_flags; }; /** @@ -502,7 +502,7 @@ struct call_media { int ptime; /* either from SDP or overridden */ - volatile unsigned int media_flags; + atomic64 media_flags; }; TYPED_GPTRARRAY(medias_arr, struct call_media) @@ -575,7 +575,7 @@ struct call_monologue { /* carry `sdp_session` attributes into resulting call monologue SDP */ str_q sdp_attributes; - volatile unsigned int ml_flags; + atomic64 ml_flags; }; TYPED_GQUEUE(monologues, struct call_monologue) @@ -711,7 +711,7 @@ struct call { int cpu_affinity; enum block_dtmf_mode block_dtmf; - unsigned int call_flags; + atomic64 call_flags; }; diff --git a/include/helpers.h b/include/helpers.h index 4160efa83..b27f7c6a2 100644 --- a/include/helpers.h +++ b/include/helpers.h @@ -427,41 +427,41 @@ INLINE double atomic64_div(const atomic64 *n, const atomic64 *d) { /*** ATOMIC BITFIELD OPERATIONS ***/ /* checks if at least one of the flags is set */ -INLINE bool bf_isset(const volatile unsigned int *u, unsigned int f) { - if ((g_atomic_int_get(u) & f)) +INLINE bool bf_isset(const atomic64 *u, const uint64_t f) { + if ((atomic64_get(u) & f)) return true; return false; } /* checks if all of the flags are set */ -INLINE bool bf_areset(const volatile unsigned int *u, unsigned int f) { - if ((g_atomic_int_get(u) & f) == f) +INLINE bool bf_areset(const atomic64 *u, const uint64_t f) { + if ((atomic64_get(u) & f) == f) return true; return false; } /* returns true if at least one of the flags was set already */ -INLINE bool bf_set(volatile unsigned int *u, unsigned int f) { - return (g_atomic_int_or(u, f) & f) ? true : false; +INLINE bool bf_set(atomic64 *u, const uint64_t f) { + return (atomic64_or(u, f) & f) ? true : false; } /* returns true if at least one of the flags was set */ -INLINE bool bf_clear(volatile unsigned int *u, unsigned int f) { - return (g_atomic_int_and(u, ~f) & f) ? true : false; +INLINE bool bf_clear(atomic64 *u, const uint64_t f) { + return (atomic64_and(u, ~f) & f) ? true : false; } -INLINE void bf_set_clear(volatile unsigned int *u, unsigned int f, bool cond) { +INLINE void bf_set_clear(atomic64 *u, const uint64_t f, bool cond) { if (cond) bf_set(u, f); else bf_clear(u, f); } /* works only for single flags */ -INLINE void bf_copy(volatile unsigned int *u, unsigned int f, - const volatile unsigned int *s, unsigned int g) +INLINE void bf_copy(atomic64 *u, const uint64_t f, + const atomic64 *s, const uint64_t g) { bf_set_clear(u, f, bf_isset(s, g)); } /* works for multiple flags */ -INLINE void bf_copy_same(volatile unsigned int *u, const volatile unsigned int *s, unsigned int g) { +INLINE void bf_copy_same(atomic64 *u, const atomic64 *s, const uint64_t g) { unsigned int old, set, clear; - old = g_atomic_int_get(s); + old = atomic64_get(s); set = old & g; clear = ~old & g; bf_set(u, set); diff --git a/include/ice.h b/include/ice.h index 7a8de82a0..8dcd7c418 100644 --- a/include/ice.h +++ b/include/ice.h @@ -95,7 +95,7 @@ struct ice_candidate_pair { struct ice_candidate *remote_candidate; const struct local_intf *local_intf; stream_fd *sfd; - volatile unsigned int pair_flags; + atomic64 pair_flags; uint32_t stun_transaction[3]; /* belongs to transaction_hash, thus agent->lock */ unsigned int retransmit_ms; struct timeval retransmit; @@ -141,7 +141,7 @@ struct ice_agent { str ufrag[2]; /* 0 = remote, 1 = local */ str pwd[2]; /* ditto */ - volatile unsigned int agent_flags; + atomic64 agent_flags; }; diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index 1262632d6..96cde2a1f 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -104,8 +104,9 @@ static void meta_stream_interface(metafile_t *mf, unsigned long snum, char *cont // mf is locked static void meta_stream_details(metafile_t *mf, unsigned long snum, char *content) { dbg("stream %lu details %s", snum, content); - unsigned int tag, media, tm, cmp, flags; - if (sscanf_match(content, "TAG %u MEDIA %u TAG-MEDIA %u COMPONENT %u FLAGS %u", + unsigned int tag, media, tm, cmp; + uint64_t flags; + if (sscanf_match(content, "TAG %u MEDIA %u TAG-MEDIA %u COMPONENT %u FLAGS %" PRIu64, &tag, &media, &tm, &cmp, &flags) != 5) return; stream_details(mf, snum, tag);