Below is the planned commit message:
Someone may continuously see CTRL-EVENT-SCAN-FAILED and not be able to connect to an AP when directly using wpa_supplicant(8) in the command line, and someone specifies ifconfig_wlan0="WPA in /etc/rc.conf will not encounter this problem because commit 5fcdc19a81115 and d06d7eb09131 use a weird way to address the problem. Even though the weird way may not successfully connect to AP every time. The problem is that sometimes net80211(4) doesn't pass the RTM_IEEE80211_SCAN to the routing socket when scan results are available. So wpa_supplicant(8) will never issue IEEE80211_IOC_SCAN_RESULTS to fetch the scan results since it is not notified by the routing socket. I have added ieee80211_notify_scan_done() (which will send RTM_IEEE80211_SCAN to user processes listened on a routing socket) in the early return part of scan_end(), and removed the weird part of libexec/rc/rc.d/wpa_supplicant.
Short links for commits mentioned above: commit 5fcdc19a81115 and d06d7eb09131