Skip to content

Conversation

@Srijeyarankesh
Copy link
Contributor

Make the WebConfig Amenity thread wait and signal it only after appropriately enabling LnF VAPs.

@Srijeyarankesh Srijeyarankesh requested a review from a team as a code owner July 29, 2025 09:48
@CLAassistant
Copy link

CLAassistant commented Jul 29, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ sjs889
❌ Srijeyarankesh


sjs889 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

wifi_ctrl_t *ctrl = get_wifictrl_obj();

if (subdoc_type != webconfig_subdoc_type_lnf) {
wifi_util_info_print(WIFI_CTRL,"%s:%d - subdoc_type:%d not supported\n", __func__, __LINE__, subdoc_type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code style: more than 100 chars in line, missing space after WIFI_CTRL,

        wifi_util_info_print(WIFI_CTRL, "%s:%d - subdoc_type:%d not supported\n", __func__,
            __LINE__, subdoc_type);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the change

wifi_sem_param_signal(&ctrl->managed_wifi_sem_param, status);
}

bool managed_wifi_cfg_sem_wait_duration(uint32_t time_in_sec, webconfig_subdoc_type_t subdoc_type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add function prototype in wifi_ctrl.h if exported

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have exported it to wifi_ctr.h file where I have added a prototype.

webconfig_analytic_event_data_to_hal_apply(data);
ret = webconfig_hal_lnf_vap_apply(ctrl, &data->u.decoded);
bool status = ((ret == RETURN_OK) ? true : false);
wifi_util_info_print(WIFI_CTRL,":%s:%d lnf blob cfg status:%d\n", __func__, __LINE__, ret);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code style: more than 100 chars in line, missing space after WIFI_CTRL,
redundant ":" at the beggining of log message, ":%s:%d lnf blob cfg status:%d\n" -> "%s:%d lnf blob cfg status:%d\n"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have made the change

Copy link
Contributor Author

@Srijeyarankesh Srijeyarankesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the changes. Can you please have a look at them again?

wifi_ctrl_t *ctrl = NULL;

ctrl = (wifi_ctrl_t *)get_wifictrl_obj();
if (!sem_param->is_init) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for sem_param not NULL before dereferencing it

pthread_mutex_unlock(&ctrl->hotspot_sem_param.lock);
static void wifi_sem_param_destroy(wifi_sem_param_t *sem_param)
{
if (sem_param->is_init) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above to check the set_param being Not NULL

{
wifi_ctrl_t *ctrl = get_wifictrl_obj();

if (subdoc_type != webconfig_subdoc_type_lnf) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for checking of subdoc_type in sem_wait_duration?

__func__, (subdoc_type == webconfig_subdoc_type_lnf) ? "lnf_psk" : "xfinity");
goto done;
}
else if(ret == RETURN_TIMEDOUT) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix code style
} else if (ret == RETURN_TIMEDOUT) {

@Srijeyarankesh
Copy link
Contributor Author

@amarnathhullur @bogdanbogush2 @narendradandu Can you please review now? Please ignore some debug prints as of now. Can you please check if code syntax and semantics are ok?

if (ret_value == false) {
wifi_util_error_print(WIFI_CTRL, "%s:%d WebConfig blob apply is failed\n", __func__,
__LINE__);
wifi_util_dbg_print(WIFI_CTRL, "%s:%d:SREESH Encoded blob:\n%s\n", __func__, __LINE__, str);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove SREESH


if (subdoc_type == webconfig_subdoc_type_lnf) {
wifi_util_info_print(WIFI_CTRL,
"%s:%d:SREESH Doing a thread wait for the managed wifi blob for %d seconds\n", __func__,
Copy link
Contributor

@bogdanbogush2 bogdanbogush2 Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove SREESH

webconfig_data_free(data);
return RETURN_TIMEDOUT;
}
} else if(subdoc_type == webconfig_subdoc_type_xfinity) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix code style

} else if (subdoc_type == webconfig_subdoc_type_xfinity) {

@amarnathhullur
Copy link
Contributor

@Srijeyarankesh, no comments from my side apart from the comments provided by @bogdanbogush2 .

@gsathish86
Copy link
Contributor

Am good with the latest changes.

wifi_util_error_print(WIFI_CTRL, "%s: failed to encode %s subdoc\n", \
__func__, (subdoc_type == webconfig_subdoc_type_lnf) ? "lnf_psk" : "xfinity");
goto done;
} else if(ret == RETURN_TIMEDOUT) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code style

} else if (ret == RETURN_TIMEDOUT) {

Comment on lines +406 to +407
bool managed_wifi_sem_wait_duration(uint32_t time_in_sec);
void managed_wifi_sem_signal(bool status);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are definitions for these?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 2032 + 2039 in wifi_ctrl.c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should name them the same way: managed_wifi_cfg_sem_wait_duration and managed_wifi_cfg_sem_signal

wifi_sem_param_signal(&ctrl->managed_wifi_sem_param, status);
}

bool managed_wifi_cfg_sem_wait_duration(uint32_t time_in_sec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add declaration for this and other function used in other translation nodes to wifi_ctrl.h

bool status = false;

wifi_ctrl_t *ctrl = NULL;
wifi_sem_param_init(sem_param);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wifi_sem_param_init(sem_param);
if (!sem_param->is_init) wifi_sem_param_init(sem_param);

(together with removal of the if condition from wifi_sem_param_init. )
That way, one unnecessary function call will be spared making the code a bit faster.

pthread_mutex_lock(&ctrl->hotspot_sem_param.lock);
ret = pthread_cond_timedwait(&ctrl->hotspot_sem_param.cond, &ctrl->hotspot_sem_param.lock, &ts);
pthread_mutex_lock(&sem_param->lock);
ret = pthread_cond_timedwait(&sem_param->cond, &sem_param->lock, &ts);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can fail. Will extra info why it help will not be helpful in this case? or is it too rare?

wifi_ctrl_t *ctrl = NULL;

ctrl = (wifi_ctrl_t *)get_wifictrl_obj();
if (sem_param && !sem_param->is_init) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (sem_param && !sem_param->is_init) {

move checking if (!sem_param -> is_init) to call place, in 2005 line.
checking whether sem_param exists doesnt make sense, since this is struct being part of object - it will always exist.

pthread_mutex_unlock(&ctrl->hotspot_sem_param.lock);
static void wifi_sem_param_destroy(wifi_sem_param_t *sem_param)
{
if (sem_param && sem_param->is_init) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above with sem_param_init please.

ctrl->hotspot_sem_param.is_init = false;
pthread_mutex_destroy(&ctrl->hotspot_sem_param.lock);
pthread_cond_destroy(&ctrl->hotspot_sem_param.cond);
wifi_sem_param_destroy(sem_param);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in line 2005:

Suggested change
wifi_sem_param_destroy(sem_param);
if (sem_param->is_init) wifi_sem_param_destroy(sem_param);


static void wifi_sem_param_signal(wifi_sem_param_t *sem_param, bool status)
{
if (sem_param && sem_param->is_init) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as with _init and _destroy methods, at least remove first part of condition

Comment on lines +406 to +407
bool managed_wifi_sem_wait_duration(uint32_t time_in_sec);
void managed_wifi_sem_signal(bool status);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 2032 + 2039 in wifi_ctrl.c

} else {
wifi_util_error_print(WIFI_CTRL, "%s:%d Managed wifi blob failed, exiting\n", __func__,
__LINE__);
webconfig_data_free(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as there are no special circumstances, please use one exit point from function.
setting int ret_value = return_XX at the end of the block improves readibility significantly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants