MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / network_multicast_receiver_stop

Function network_multicast_receiver_stop

src/network.c:1901–1952  ·  view source on GitHub ↗

* \brief Stop multicast receiver * * Stop multicast receiver * * \return RIG_OK or < 0 if error */

Source from the content-addressed store, hash-verified

1899 * \return RIG_OK or < 0 if error
1900 */
1901int network_multicast_receiver_stop(RIG *rig)
1902{
1903 struct rig_state *rs = STATE(rig);
1904 multicast_receiver_priv_data *mcast_receiver_priv;
1905
1906 ENTERFUNC;
1907
1908 rs->multicast_receiver_run = 0;
1909
1910 mcast_receiver_priv = (multicast_receiver_priv_data *)
1911 rs->multicast_receiver_priv_data;
1912
1913 if (mcast_receiver_priv == NULL)
1914 {
1915 RETURNFUNC(RIG_OK);
1916 }
1917
1918 // Close the socket first to stop the routine
1919 if (mcast_receiver_priv->args.socket_fd >= 0)
1920 {
1921#ifdef __MINGW32__
1922 shutdown(mcast_receiver_priv->args.socket_fd, SD_BOTH);
1923#else
1924 shutdown(mcast_receiver_priv->args.socket_fd, SHUT_RDWR);
1925#endif
1926 close(mcast_receiver_priv->args.socket_fd);
1927 }
1928
1929 if (mcast_receiver_priv->thread_id != 0)
1930 {
1931 int err = pthread_join(mcast_receiver_priv->thread_id, NULL);
1932
1933 if (err)
1934 {
1935 rig_debug(RIG_DEBUG_ERR, "%s(%d): pthread_join error %s\n", __FILE__, __LINE__,
1936 strerror(errno));
1937 // just ignore it
1938 }
1939
1940 mcast_receiver_priv->thread_id = 0;
1941 }
1942
1943 if (mcast_receiver_priv->args.socket_fd >= 0)
1944 {
1945 mcast_receiver_priv->args.socket_fd = -1;
1946 }
1947
1948 free(rs->multicast_receiver_priv_data);
1949 rs->multicast_receiver_priv_data = NULL;
1950
1951 RETURNFUNC(RIG_OK);
1952}
1953
1954/** @} */

Callers 2

rig_closeFunction · 0.85
network.hFile · 0.85

Calls 2

pthread_joinFunction · 0.85
rig_debugFunction · 0.85

Tested by

no test coverage detected